BuddhiLW
BuddhiLW

Reputation: 627

Golang CORS doesn't accept the given ip, nor '*'

I'm using a Golang backend, which can be found in this repository: https://github.com/BuddhiLW/free-riding

I'm using the given command, using the fasthttp package,

ctx.Response.Header.Set("Access-Control-Allow-Origin", "*")

I also tried replacing "*" with "161.35.yy.xxx:*" which is the ip for my droplet.

When I run locally, using exactly the same setup, it works:

sudo docker run -dit --name my-running-frontend -p 8080:80 clojurescript-frontend
sudo docker run -it --rm --name my-running-backend -p 8181:8181 golang-backend

But, remotely, when I go to 161.35.yy.xxx:80, and use the service, I get CORS error.

The error, in the console:

main.js:3779     GET http://localhost:8181/free-riding/duckduckgo.com net::ERR_CONNECTION_REFUSED

And:

Access to XMLHttpRequest at 'http://localhost:8181/free-riding/duckduckgo.com' from origin 'http://161.35.96.204:8000' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.

In the Network tab:

Request URL:
http://localhost:8181/free-riding/duckduckgo.com
Referrer Policy:
strict-origin-when-cross-origin

Upvotes: 0

Views: 155

Answers (0)

Related Questions