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 headers not sent for some redirects #8501

Open
3 tasks done
ghost opened this issue Oct 9, 2021 · 0 comments
Open
3 tasks done

CORS headers not sent for some redirects #8501

ghost opened this issue Oct 9, 2021 · 0 comments
Labels
kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up topic/gateway Topic gateway

Comments

@ghost
Copy link

ghost commented Oct 9, 2021

Checklist

Installation method

ipfs-update or dist.ipfs.io

Version

go-ipfs version: 0.10.0
Repo version: 11
System version: amd64/linux
Golang version: go1.16.8

Config

No response

Description

cors headers are properly sent for redirects to ipfs.localhost:8080:

$ curl -I localhost:8080/ipfs/QmVCYUK51Miz4jEjJxCq3bA6dfq5FXD6s2EYp6LjHQhGmh/meta
HTTP/1.1 301 Moved Permanently
Accept-Ranges: bytes
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Headers: Range
Access-Control-Allow-Headers: User-Agent
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Range
Access-Control-Expose-Headers: X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Output
Cache-Control: public, max-age=29030400, immutable
Content-Length: 26
Content-Type: application/octet-stream
Etag: "QmbaoVNrRZjpxjEYe96qMbPQGk6yHG3az5izWbxurQ7L1F"
Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
Location: http://bafybeidf5yn56cxk6zkyjmay4wigu2o7ynqh7q62z3kppag5v7jpqavy5q.ipfs.localhost:8080/meta
X-Ipfs-Path: /ipfs/QmVCYUK51Miz4jEjJxCq3bA6dfq5FXD6s2EYp6LjHQhGmh/meta
Date: Sat, 09 Oct 2021 00:11:06 GMT

and cors headers are properly sent according to the configuration for properly-formatted paths:

$ curl -I -H 'host: bafybeidf5yn56cxk6zkyjmay4wigu2o7ynqh7q62z3kppag5v7jpqavy5q.ipfs.localhost:8080' localhost:8080/meta
HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Headers: Range
Access-Control-Allow-Headers: User-Agent
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Range
Access-Control-Expose-Headers: X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Output
Cache-Control: public, max-age=29030400, immutable
Content-Length: 26
Content-Type: application/octet-stream
Etag: "QmbaoVNrRZjpxjEYe96qMbPQGk6yHG3az5izWbxurQ7L1F"
Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
X-Ipfs-Path: /ipfs/bafybeidf5yn56cxk6zkyjmay4wigu2o7ynqh7q62z3kppag5v7jpqavy5q/meta
Date: Sat, 09 Oct 2021 00:06:00 GMT

but if there is an extra / in the path, the headers are NOT sent:

$ curl -I localhost:8080/ipfs/QmVCYUK51Miz4jEjJxCq3bA6dfq5FXD6s2EYp6LjHQhGmh//meta
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: /ipfs/QmVCYUK51Miz4jEjJxCq3bA6dfq5FXD6s2EYp6LjHQhGmh/meta
Date: Sat, 09 Oct 2021 00:13:09 GMT

This took hours for me to figure out why I couldn't fetch() from a localhost domain to the daemon running on localhost:8080 despite my configuration with CORS enabled.

@ghost ghost added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Oct 9, 2021
@guseggert guseggert added P2 Medium: Good to have, but can wait until someone steps up topic/gateway Topic gateway and removed need/triage Needs initial labeling and prioritization labels Aug 5, 2022
@guseggert guseggert added this to the Best Effort Track milestone Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up topic/gateway Topic gateway
Projects
No open projects
Status: 🥞 Todo
Development

No branches or pull requests

2 participants