Closed
Description
- Gitea version (or commit ref): 27c1578
- Git version: 2.25.1
- Operating system:
Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- No
- Log gist:
Description
This feature #5719(#5700) can not work now.
The browser say:
Access to XMLHttpRequest at 'http://localhost:3000/name/repo.git/info/refs?service=git-upload-pack' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
And the response header has nothing CORS header return.
The server report:
Completed OPTIONS /name/repo.git/info/refs?service=git-upload-pack 405 Method Not Allowed in 780.91µs
I've found it was incorrectly rejected before entering httpBase.
Line 150 in 27c1578
The context.Contexter()
reject it.
Just add the following code before context.Contexter()
to fix:
common = append(common, CorsHandler) // added here
// Removed: toolbox.Toolboxer middleware will provide debug informations which seems unnecessary
common = append(common, context.Contexter())