Valkyrie: CORS Error
I app works fine on local host but when i convert my localhost to a public URL using ngrok or localtunnel it gives me the following CORS error
Access to XMLHttpRequest at 'http://localhost:4000/api/account/register' from origin 'https://animeea.loca.lt' 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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 43 (20 by maintainers)
If you mean cors issues then no, since cors is related to browsers.
Sadly there isn’t really a good way to host stuff for free. By the way, you need to set the variables in the settings tab and the config vars fields. But as I said you won’t be able to run the project without one of the paid tiers on Heroku.
Heroku offers add-on you can easily attach to your app.
I use Heroku to host the server and Netlify to host the website. You would need to use the paid tier to fully host the project since Heroku’s free tier doesn’t allow custom domains.
Github is the best way to contact me.
I think your server needs to run with the same domain, like
https://api.animeea.loca.lt
. I would recommend searching something like “localtunnel cors” and following some of the results.I’m not familiar with localtunnel so I don’t know if it needs extra setup. I checked my environment variables and the only addition I have is that I set
GIN_MODE
torelease
.Where is your web client hosted?
You also need to change the
CORS_ORIGIN
variable.Mine is set to
https://valkyrieapp.xyz
for example, while the domain is set to.valkyrieapp.xyz
.Did you set the
domain
variable in the environment, since it still says localhost in the error?