atlas
atlas copied to clipboard
Request blocked by CORS policy
Has anyone encountered the following error message while trying to send requests?
Access to XMLHttpRequest at 'http://localhost:8222/create' from origin 'http://localhost:3004' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Can't figure out how to remedy the issue.
My cors config currently looks like this (after trying both the example and many variations):
app :: Ctx -> Application
app ctx = cors (const $ Just simpleCorsResourcePolicy { corsOrigins = Just (["http://127.0.0.1:3004"], True), corsRequestHeaders = [HttpTypes.hContentType, HttpTypes.hAccept, HttpTypes.hAuthorization] }) $ serve appApi $ hoistServer appApi (Handler . ExceptT . try) $ apiServer ctx```
Hi mate, this isn't really related to Atlas. I would suggest creating a simple reproducible example (just a dummy server) and trying to debug with it (perhaps mention at stackoverflow?), can also describe raw request which is being blocked.
Since there has been no activity in this issue for a while, I'll be closing it. Feel free to reopen it.