Skip to content

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented May 28, 2025

Allows remote access from a browser sandbox if exposed.

I needed this for some browser dev work to talk to my local node, and I have it running now and it's 👌.

Closes: #6402

@Copilot Copilot AI review requested due to automatic review settings May 28, 2025 04:25
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz May 28, 2025
Allows remote access from a browser sandbox if exposed

Closes: #6402
@rvagg rvagg force-pushed the rvagg/gateway-cors branch from d348d52 to 42692c6 Compare May 28, 2025 04:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds optional CORS header support to the gateway when the --cors flag is provided.

  • Introduce enableCORS option in handler configuration and a WithCORS functional option
  • Wrap the main HTTP handler with a new CORSHandler when enabled
  • Expose a --cors CLI flag in lotus-gateway to toggle CORS support

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
gateway/handler.go Added enableCORS option, CORSHandler type and wrapper; conditionally wrap handler
cmd/lotus-gateway/main.go Introduce --cors flag and pass its value into WithCORS
Comments suppressed due to low confidence (1)

gateway/handler.go:318

  • There are no tests covering the new CORSHandler; consider adding unit tests to verify that CORS headers are correctly set and that preflight (OPTIONS) requests are handled.
func (h *CORSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from 📌 Triage to ✔️ Approved by reviewer in FilOz May 28, 2025
@ZenGround0
Copy link
Contributor

We've got some failing tests

@rjan90
Copy link
Contributor

rjan90 commented May 28, 2025

We've got some failing tests

At least the eth_api_f3 has been consistently failing for some time now: #13116.

@rvagg rvagg merged commit 1badd5f into master May 28, 2025
95 of 96 checks passed
@rvagg rvagg deleted the rvagg/gateway-cors branch May 28, 2025 23:40
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎉 Done
Development

Successfully merging this pull request may close these issues.

Add CORS headers
3 participants