What is 'Access-Control-Allow-Origin'? And how to handle it in go?

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.

The Access-Control-Allow-Origin response header indicates whether the response can be shared with resources with the given origin or all origin check https: // developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin, i.e.,

Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: <origin>

Where origin is uri.

to set header in go use Header.Add:


Hope this answers your question.

1 Like

thank you so much .

In case you prefer an implementation that’s easy to plug into a HTTP router, check this package.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.