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 test sends non-CORS request #217

Open
achingbrain opened this issue Jul 9, 2024 · 1 comment
Open

CORS test sends non-CORS request #217

achingbrain opened this issue Jul 9, 2024 · 1 comment

Comments

@achingbrain
Copy link
Member

There's a test:

"GET Responses from Gateway should include CORS headers allowing JS from other origins to read the data cross-origin."

It makes a GET request to "/ipfs/{{CID}}/" and expects Access-Control-Allow-Origin etc in the response.

The test sends:

GET /ipfs/bafkqabtimvwgy3yk/ HTTP/1.1
Host: host.docker.internal:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip

The fetch spec says:

A CORS request is an HTTP request that includes an Origin header. It cannot be reliably identified as participating in the CORS protocol as the Origin header is also included for all requests whose method is neither GET nor HEAD.

There is no Origin header in the request, so this is not a CORS request.

Why does the test expect CORS headers in the response?

@achingbrain
Copy link
Member Author

achingbrain commented Jul 9, 2024

I would say also, the GET test expects the following headers to be present in the response:

  • Access-Control-Allow-Origin
  • Access-Control-Allow-Methods
  • Access-Control-Allow-Headers
  • Access-Control-Expose-Headers

Of these only Access-Control-Allow-Origin is valid in the response to a CORS request, the others are for a CORS-preflight request (e.g. OPTIONS, not GET) so I don't think this test is valid. Ref - https://fetch.spec.whatwg.org/#http-responses

Is it just asserting on the behaviour of the go-HTTP server? There's no mention of CORS in any of the HTTP Gateway specs so it's unclear what's intended to happen here.

achingbrain added a commit to ipfs/helia-http-gateway that referenced this issue Jul 9, 2024
Skips practically all of them to just get the framework in place.

I'm not sure all the tests are valid, the spec is missing large
chunks of functionality asserted in the tests, but the assertions
don't necessarily assert IETF/W3c spec compliant behaviour, for
example: ipfs/gateway-conformance#217
achingbrain added a commit to ipfs/helia-http-gateway that referenced this issue Jul 10, 2024
Skips practically all of them to just get the framework in place.

I'm not sure all the tests are valid, the spec is missing large
chunks of functionality asserted in the tests, but the assertions
don't necessarily assert IETF/W3c spec compliant behaviour, for
example: ipfs/gateway-conformance#217
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

No branches or pull requests

1 participant