You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gitea has hardcoded what headers are permitted via CORS. This list does not include "Content-Type", which is needed in order to get browsers to POST JSON data to the Gitea backend.
The middleware rejects this preflight, since the content-type header is not hardcoded in the application. After adding "Debug: true" to the cors.Handler call (see top snippet), the rejection can be seen in the Gitea logs.
Gitea Output
2022/11/09 16:42:17 cmd/web.go:106:runWeb() [I] Starting Gitea on PID: 22617
2022/11/09 16:42:17 cmd/web.go:157:runWeb() [I] Global init
[...]
[cors] 2022/11/09 17:23:17 Handler: Preflight request
[cors] 2022/11/09 17:23:17 Preflight aborted: headers '[Authorization Content-Type]' not allowed
2022/11/09 17:23:17 [636c2855] router: completed OPTIONS /api/v1/repos/some_org/some_repo/issues for 172.23.64.1:63690, 200 OK in 0.1ms @ unknown-handler
This PR enhances the CORS middleware usage by allowing for the headers
to be configured in `app.ini`.
Fixes#21746
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Description
Gitea has hardcoded what headers are permitted via CORS. This list does not include "Content-Type", which is needed in order to get browsers to POST JSON data to the Gitea backend.
gitea/routers/api/v1/api.go
Lines 614 to 622 in 5a6cba4
Ideally this would be customizable via a configuration file, but at the least include "Content-Type".
JS Example
Preflight
The middleware rejects this preflight, since the content-type header is not hardcoded in the application. After adding "Debug: true" to the
cors.Handler
call (see top snippet), the rejection can be seen in the Gitea logs.Gitea Output
Gitea Version
1.17.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
https://gist.github.com/drewmnoel/e771b9f47d96846aeaea02263f44486a
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Gitea build information:
I'm running on the command line with the following section added to the default app.ini:
Database
No response
The text was updated successfully, but these errors were encountered: