Skip to content
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

CORS preflight OPTIONS request to API returns 404 #5724

Closed
2 of 7 tasks
salcedo opened this issue Jan 14, 2019 · 10 comments · Fixed by #6289
Closed
2 of 7 tasks

CORS preflight OPTIONS request to API returns 404 #5724

salcedo opened this issue Jan 14, 2019 · 10 comments · Fixed by #6289
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality

Comments

@salcedo
Copy link

salcedo commented Jan 14, 2019

  • Gitea version (or commit ref): 1.6.1
  • Git version: 2.20.1
  • Operating system: OpenBSD 6.4
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I'm working on a project that will make some requests to Gitea's API. As my project is on a different origin, my browser sends a CORS preflight (an OPTIONS request).

Gitea doesn't handle an OPTIONS request, and returns 404.

How to fix?

Works:

curl -X GET https://git.example.com/api/v1/repos/search

Returns 404:

curl -X OPTIONS https://git.example.com/api/v1/repos/search

Screenshots

@techknowlogick
Copy link
Member

Closed as duplicate of #5700

There is a PR in works to resolve this

@techknowlogick techknowlogick added the issue/duplicate The issue has already been reported. label Jan 14, 2019
@JuhoHeiskanen
Copy link

This issue is technically not a duplicate since #5700 deals with the git smart http protocol, not the Gitea API. Pull #5719 that closed the "duplicate" issue does not resolve this one.

@techknowlogick
Copy link
Member

Access-Control-Allow-Origin header And OPTIONS method response were implemented with that ticket the users purpose may have been for different purposes but they indeed accomplished the same goal

@JuhoHeiskanen
Copy link

As far as I can tell, the Gitea API is unaffected by that change. The change does not seem to affect the /api/v1/repos/search endpoint.

@JuhoHeiskanen
Copy link

To be more clear, the pull did not implement CORS header support for the API, but it did implement support for them in git-over-http.

@techknowlogick
Copy link
Member

That’s helpful information. Thanks :)

@techknowlogick techknowlogick removed the issue/duplicate The issue has already been reported. label Jan 23, 2019
@lafriks lafriks added the type/enhancement An improvement of existing functionality label Jan 23, 2019
@FallingSnow
Copy link

It seems that Gitea doesn't add cors headers to non-option requests either. Cors headers are required on both preflight OPTION requests as well as the following intended requests.

@stale
Copy link

stale bot commented Apr 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Apr 1, 2019
@lunny lunny added issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented and removed issue/stale labels Apr 2, 2019
@klappy
Copy link

klappy commented Apr 16, 2019

Has anybody made progress or found a functional work around for this issue?

@techknowlogick
Copy link
Member

Current workaround would be to use a reverse proxy that intercepts the request needed and returns the appropriate response.

There is a pending PR for this, however it is awaiting updates from contributor.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants