Description
Gitea Version
1.15.2
Operating System
Windows
How are you running Gitea?
Localhost
Can you reproduce the bug on the Gitea demo site?
Yes
Description
CORS both for 'POST/PATCH' API and for 'GET' attachment or assets are not working
Access to XMLHttpRequest at 'http://localhost:330/attachments/b95d46d2-8fe9-4529-8bde-c5bddfe08286' from
origin 'https://hoppscotch.io' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I am building a PWA and using REST API get access to issues and comments of self hosted Gitea. There are servial issues about CORS:
-
CORS works only for 'GET' method. And never set ’Access-Control-Allowed-Origin: *‘ for 'POST', 'PATCH' etc.
// after using a chrome extension 'Corss Domain', it adds the response headers ’Access-Control-Allowed-Origin: *‘ for 'POST', 'PATCH', and my PWA works. -
CORS works only for REST API not for ASSETS.
As we known, CORS http method call after an 'OPTIONS' prelight request. However, 'OPTIONS’ method was not allowed for attachement assets request. It just return '405 method not allowed' while I access to the resource CORS way, using the right token.
// I have not found a Chrome extension to fix the reponse code for options access to assets yet.
// so the issue blocked.
Gitlab API provides the right response code and headers about CORS API access from different domains.
Hoping Gitea can improve the CORS implements and configration.