cors icon indicating copy to clipboard operation
cors copied to clipboard

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

Open MrMu666 opened this issue 4 years ago • 2 comments

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?

MrMu666 avatar Aug 04 '20 10:08 MrMu666

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

acherifi avatar Sep 26 '20 19:09 acherifi

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.

akhanchouch avatar Dec 23 '20 15:12 akhanchouch