Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different usages of "/" at the end of urls between frontend and backend can cause an CORS error #68

Open
MrMu666 opened this issue Aug 4, 2020 · 2 comments

Comments

@MrMu666
Copy link

MrMu666 commented Aug 4, 2020

If there is a scenario like this:
The url in javascript of frontend is "http://localhost:8888/thedata",
And the url in gin is "http://localhost:8888/thedata/", Please notice the slash sign in the end ,
Then, the browser will reports a CORS error. It's been bothering me for a long time. I couldn't find an explanation for this on Google. Am I the only one who has found this problem?

@acherifi
Copy link

acherifi commented Sep 26, 2020

It may cause a CORS error but if I try to curl

http://myservice/route/

And have it define with

http://myservice/route

in Gin, it will result in a Moved permanently response from the server.
I think this issue is more related to Gin than the CORS module here but I might be wrong

@akhanchouch
Copy link

I think CORS module doesn't support redirection .
I made the same mistake by leaving a slash at the end of the url, it shows CORS issue. I have tried different configuration of CORS module with no success as if my config isn't running. I altred the origin value of the request with gin server url the result was a redirection and a success. So that made me think that CORS module doesn't support redirection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants