Cross Origin Request Blocked


#1

I’ve built an API using Echo, things work great in Postman when I’m making requests. However, when I make requests through the React front end that I’ve put togeather I get an error.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
http://localhost:2000/users/auth. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

This type of thing is expected when you have an app making a call to another domain, but my Echo server is using the default configuration of e.Use(middleware.CORS()). Is there something else I should be doing to send Access-Control-Allow-Origin headers?


#2

I discovered my problem yesterday. Apparently I was querying a mistyped URL and echo was responding with a 400 error because it expected an authentication token. Firefox was diagnosing the response in the console as CORS not being configured appropriately.