Comments (7)
@Louis-Amas I almost forget this issue, I just changed my client request to sth like .../v1/foo/
Add '/' symbol at the end of the url to prevent redirection.
from cors.
this same problem using
In r.Group
Did you find a fix ?
from cors.
Id didnt work out. I did this according to your recommendation, but client side still throws CORS error.
from cors.
It is not caused by gin-contrib/cors, it's caused by gin.
For "TrailingSlash" redirections, the process will get out before entering any middlewares.
from cors.
@Louis-Amas I almost forget this issue, I just changed my client request to sth like .../v1/foo/ Add '/' symbol at the end of the url to prevent redirection.
just in case you write '/' in the end of your url at golang server ( like /v1/foo/).
If you don't write it (like /v1/foo ), don't add '/' on your request url.
from cors.
You may want to check this answer gin-gonic/gin#1216 ...
router := gin.New()
friend := router.Group("/friend")
{
friend.GET("/", controller.GetFirends)
}
Your router sets the handler to /friend/ path. You should use
router.GET("", controller.GetFirends)
if you want to use/friend
:(without trailing slash).
from cors.
You may want to check this answer gin-gonic/gin#1216
I think the issue persist even setting specific route to .GET("", controller....)
and calling /
at the end of the path
My workaround: duplicate routes
router := gin.New()
friend := router.Group("/friend")
{
friend.GET("/", controller.GetFirends)
friend.GET("", controller.GetFirends)
}
So even if you call /friend
or /friend/
no 301 redirect is returned
from cors.
Related Issues (20)
- Snyk vulnerability HTTP Response Splitting on older version of github.com/gin-gonic/gin HOT 3
- Shouldn't Be Returning * When Allow-Credentials and Allow-All-Origins are Set to True
- React & React Native Issue
- update README file
- Allow All Headers
- No way to disable caching of CORS-preflight responses
- Users currently cannot allow methods that are not uppercase HOT 1
- Repo documentatoin website (github pages URL) is broken - 404 error HOT 1
- Allow All Origin header not added in the response HOT 8
- Weird Access-Control-Allow-Headers CORS Bug HOT 1
- Register tauri:// scheme (or allow custom schemes upstream?)
- Cors error HOT 2
- error in parseWildcardRules when asterisk at the end HOT 2
- Timing-Allow-Origin support
- CORS not working, even with `cors.Default()` HOT 1
- Feature Proposal: Config.MatchPaths HOT 1
- it doesn't work HOT 11
- I can't use cors.default() to allow all origin haeder. HOT 5
- [Notice] Preflight with no origin will return OPTIONS 404 HOT 1
- CORS error with added header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cors.