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

fix: create options api for cors preflight request. #2598

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Conversation

kaichaosun
Copy link
Contributor

@kaichaosun kaichaosun commented Apr 17, 2024

Description

CORS request triggers an Options request to same endpoint. More context.
The changes here will fix send REST API request from web browser to local nwaku node.

Changes

  • Access-Control-Allow-Headers set to Content-Type, this is needed to fix error Reason: header ‘content-type’ is not allowed according to header ‘Access-Control-Allow-Headers’
  • Options method enabled in relay rest api.

Copy link

github-actions bot commented Apr 17, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2598-rln-v2-true

Built from dc496bb

Copy link
Contributor

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

Awesome!!! Thank you for this extension!
Should we have similar OPTION method handlers for all the enpoint paths?

@kaichaosun
Copy link
Contributor Author

kaichaosun commented Apr 17, 2024

@NagyZoltanPeter We can add OPTIONS for other endpoints when people requesting it, not sure if it's a best practice though. Prefer not adding too much boilerplate code.

@NagyZoltanPeter
Copy link
Contributor

@NagyZoltanPeter We can add OPTIONS for other endpoints when people requesting it, not sure if it's a best practice though. Prefer not adding too much boilerplate code.

@kaichaosun Do you think it worth to make some more generic solution for it? I think of, in case allow-origin is configured we should auto add OPTION to each installed endpoint?
Current Presto implementation supports a chain of middleware callbacks can be installed, within such we could handle OPTION calls by checking valid paths.

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!
@kaichaosun - let's make sure all tests pass before merging :)
The only ones that we expect to fail are the js-waku jobs, which will be fixed soon

@kaichaosun
Copy link
Contributor Author

@NagyZoltanPeter A generic and auto solution for all endpoints would be great. I will create an issue to track it.

@kaichaosun
Copy link
Contributor Author

Force pushed for verified commit. @Ivansete-status

@kaichaosun kaichaosun merged commit 768c61b into master Apr 18, 2024
13 of 15 checks passed
@kaichaosun kaichaosun deleted the rest-options branch April 18, 2024 10:29
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