-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
Brings js-ipfs into line with go-ipfs by not having CORS on by default, instead requiring the user to explicitly configure it. BREAKING CHANGE: - CORS origins will need to be [configured manually](https://github.com/ipfs-inactive/js-ipfs-http-client#cors)
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Browsers send OPTIONS requests as preflight CORS checks when the client has done something like specified custom headers. Removes the blanket 405 handlers in order to use HAPI's default 404 when the preflight request-method is for a resource that does not exist, though retain the 405 behaviour if a request with a non-POST or non-OPTION method is actually received.
"The origin server MUST generate an Allow header field in a 405 response containing a list of the target resource's currently supported methods." https://tools.ietf.org/html/rfc7231#section-6.5.5
I've changed the default behaviour of the non- The previous implementation was adding extra handlers for To me it doesn't make sense to send a I've moved the TBH it's not a big deal as the pre-flight response is opaque to the client js if it doesn't have a As an added bonus we now send an |
I want to test this against https://webui.ipfs.io +/- CORS, but we are in the middle of release, so need to wait a bit before I get to it. Will post my review later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CORS works as expected, but I think there is a regression related to /webui
on API port:
- 💚 https://webui.ipfs.io is unable to use API at
http://127.0.0.1:5002
without CORS safelisting - 💚 https://webui.ipfs.io is able to use API at
http://127.0.0.1:5002
when CORS safelisting is done viajsipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["https://webui.ipfs.io"]'
before starting the daemon - 💔 The WebUI URL printed to the console during
jsipfs daemon
start is broken:http://127.0.0.1:5002/webui
returns405 Method Not Allowed
Co-authored-by: Marcin Rataj <lidel@lidel.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPTIONS, WebUI (local or remote) look fine now.
Small nit below, but other than that lgtm.
Co-authored-by: Marcin Rataj <lidel@lidel.org> Brings js-ipfs into line with go-ipfs by not having CORS on by default, instead requiring the user to explicitly configure it. BREAKING CHANGE: - CORS origins will need to be [configured manually](https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-http-client/README.md#cors) before use with ipfs-http-client
Brings js-ipfs into line with go-ipfs by not having CORS on by default, instead requiring the user to explicitly configure it.
BREAKING CHANGE: