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

config flag to enable CORS response headers for data downloads #834

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

emizzle
Copy link
Contributor

@emizzle emizzle commented Jun 14, 2024

This is needed when downloading data from a browser, eg the ethcc-demo

@@ -166,6 +168,12 @@ proc initDataApi(node: CodexNodeRef, repoStore: RepoStore, router: var RestRoute
Http400,
$cid.error())

if corsOrigin =? allowedOrigin:
Copy link
Member

Choose a reason for hiding this comment

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

OK for now, in the future we should probably think of a CORS config mechanism for presto so we don't have to manually set per-endpoint like this (maybe we can tackle this issue).

Copy link
Member

@gmega gmega left a comment

Choose a reason for hiding this comment

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

Good for immediate needs, we should probably think of a follow up on presto to pull this from here in the long run.

Comment on lines +172 to +176
resp.setHeader("Access-Control-Allow-Origin", corsOrigin)
resp.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS")
resp.setHeader("Access-Control-Headers", "X-Requested-With")
resp.setHeader("Access-Control-Max-Age", "86400")

Copy link
Member

Choose a reason for hiding this comment

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

This is repeated twice, can we extract this to a proc, or a template?

@gmega gmega added this pull request to the merge queue Jun 17, 2024
Merged via the queue into master with commit e422c90 Jun 17, 2024
10 checks passed
@gmega gmega deleted the feat/rest/allow-cors-for-downloads branch June 17, 2024 12:34
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