-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use middleware but not new routers for http cors #16566
Conversation
You still need the OPTIONS routes in otherwise the main CORS handler will fire instead and we'll be back at the point that caused me having to add them in in the first place in #16496. |
The middleware have checked the OPTIONS method. Why we still need the routes? |
ca95313
to
0ef99e5
Compare
HTTPCors will never see the options request as they will not be routed to it. |
0ef99e5
to
3fb5683
Compare
OK. You are right. It seems group middlewares will not be fired if no the method handler in this group. |
3fb5683
to
912162d
Compare
routers/web/web.go
Outdated
m.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", repo.GetLooseObject) | ||
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile) | ||
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile) | ||
m.Options("/", func(ctx *context.Context) {}) // to ensure middlewares could handle options requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU This isn't going to fire on OPTIONS /git-upload-pack etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review again.
f1259f3
to
8209365
Compare
eb801f0
to
00a211e
Compare
#24303 fixed the old CORS handler. |
GetOptions
/PostOptions
back toGet
/Post
ACCESS_CONTROL_ALLOW_ORIGIN