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

Support method OPTIONS for CORS #500

Merged

Conversation

nobiit
Copy link
Contributor

@nobiit nobiit commented Sep 11, 2022

Description

Currently, Prefight request (OPTIONS method) is not supported, will cause CORS error

Motivation and Context

How Has This Been Tested?

  • Rebuild docker image
  • Run the following command from terminal in container
$ curl -v -X OPTIONS -H 'Origin: https://example.com' -H 'Access-Control-Request-Method: GET' http://localhost:18000/api/v1/health
*   Trying ::1:18000...
* TCP_NODELAY set
* connect to ::1 port 18000 failed: Connection refused
*   Trying 127.0.0.1:18000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 18000 (#0)
> OPTIONS /api/v1/health HTTP/1.1
> Host: localhost:18000
> User-Agent: curl/7.68.0
> Accept: */*
> Origin: https://example.com
> Access-Control-Request-Method: GET
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 204 No Content
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET
< Access-Control-Allow-Origin: *
< Vary: Origin
< Vary: Access-Control-Request-Method
< Vary: Access-Control-Request-Headers
< Date: Sun, 11 Sep 2022 08:36:16 GMT
< 
* Connection #0 to host localhost left intact
  • Run by fetch/xhr in my project

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

@nothing0012 nothing0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov-commenter
Copy link

Codecov Report

Merging #500 (b7d8c3d) into main (df753eb) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #500   +/-   ##
=======================================
  Coverage   80.96%   80.96%           
=======================================
  Files          28       28           
  Lines        2222     2222           
=======================================
  Hits         1799     1799           
  Misses        334      334           
  Partials       89       89           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@nothing0012 nothing0012 merged commit 81b3b9e into openflagr:main Sep 20, 2022
@nobiit
Copy link
Contributor Author

nobiit commented Sep 20, 2022

Thanks @nothing0012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants