-
-
Notifications
You must be signed in to change notification settings - Fork 688
Doc cors spec compliance #4202
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
Merged
Merged
Doc cors spec compliance #4202
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -261,12 +261,22 @@ const readableWebStream = response.body | |||||
| const readableNodeStream = Readable.fromWeb(readableWebStream) | ||||||
| ``` | ||||||
|
|
||||||
| #### Specification Compliance | ||||||
| ## Specification Compliance | ||||||
|
|
||||||
| This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org) that Undici does | ||||||
| This section documents parts of the [HTTP/1.1](https://www.rfc-editor.org/rfc/rfc9110.html) and [Fetch Standard](https://fetch.spec.whatwg.org) that Undici does | ||||||
| not support or does not fully implement. | ||||||
|
|
||||||
| ##### Garbage Collection | ||||||
| #### CORS | ||||||
|
|
||||||
| Unlike browsers, Undici does not implement CORS (Cross-Origin Resource Sharing) checks by default. This means: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
"by default" makes it sound like there is a way to enable CORS.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Will address if a new PR is created for the suggestion above. |
||||||
|
|
||||||
| - No preflight requests are automatically sent for cross-origin requests | ||||||
| - No validation of `Access-Control-Allow-Origin` headers is performed | ||||||
| - Requests to any origin are allowed regardless of the source | ||||||
|
|
||||||
| This behavior is intentional for server-side environments where CORS restrictions are typically unnecessary. If your application requires CORS-like protections, you will need to implement these checks manually. | ||||||
|
|
||||||
| #### Garbage Collection | ||||||
|
|
||||||
| * https://fetch.spec.whatwg.org/#garbage-collection | ||||||
|
|
||||||
|
|
@@ -307,7 +317,7 @@ const headers = await fetch(url, { method: 'HEAD' }) | |||||
| .then(res => res.headers) | ||||||
| ``` | ||||||
|
|
||||||
| ##### Forbidden and Safelisted Header Names | ||||||
| #### Forbidden and Safelisted Header Names | ||||||
|
|
||||||
| * https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name | ||||||
| * https://fetch.spec.whatwg.org/#forbidden-header-name | ||||||
|
|
@@ -316,7 +326,7 @@ const headers = await fetch(url, { method: 'HEAD' }) | |||||
|
|
||||||
| The [Fetch Standard](https://fetch.spec.whatwg.org) requires implementations to exclude certain headers from requests and responses. In browser environments, some headers are forbidden so the user agent remains in full control over them. In Undici, these constraints are removed to give more control to the user. | ||||||
|
|
||||||
| ### `undici.upgrade([url, options]): Promise` | ||||||
| #### `undici.upgrade([url, options]): Promise` | ||||||
|
|
||||||
| Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details. | ||||||
|
|
||||||
|
|
@@ -378,20 +388,15 @@ Returns: `URL` | |||||
| * **protocol** `string` (optional) | ||||||
| * **search** `string` (optional) | ||||||
|
|
||||||
| ## Specification Compliance | ||||||
|
|
||||||
| This section documents parts of the HTTP/1.1 specification that Undici does | ||||||
| not support or does not fully implement. | ||||||
|
|
||||||
| ### Expect | ||||||
| #### Expect | ||||||
|
|
||||||
| Undici does not support the `Expect` request header field. The request | ||||||
| body is always immediately sent and the `100 Continue` response will be | ||||||
| ignored. | ||||||
|
|
||||||
| Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1 | ||||||
|
|
||||||
| ### Pipelining | ||||||
| #### Pipelining | ||||||
|
|
||||||
| Undici will only use pipelining if configured with a `pipelining` factor | ||||||
| greater than `1`. Also it is important to pass `blocking: false` to the | ||||||
|
|
@@ -412,7 +417,7 @@ aborted. | |||||
| * Refs: https://tools.ietf.org/html/rfc2616#section-8.1.2.2 | ||||||
| * Refs: https://tools.ietf.org/html/rfc7230#section-6.3.2 | ||||||
|
|
||||||
| ### Manual Redirect | ||||||
| #### Manual Redirect | ||||||
|
|
||||||
| Since it is not possible to manually follow an HTTP redirect on the server-side, | ||||||
| Undici returns the actual response instead of an `opaqueredirect` filtered one | ||||||
|
|
@@ -421,9 +426,9 @@ implementations in Deno and Cloudflare Workers. | |||||
|
|
||||||
| Refs: https://fetch.spec.whatwg.org/#atomic-http-redirect-handling | ||||||
|
|
||||||
| ## Workarounds | ||||||
| ### Workarounds | ||||||
|
|
||||||
| ### Network address family autoselection. | ||||||
| #### Network address family autoselection. | ||||||
|
|
||||||
| If you experience problem when connecting to a remote server that is resolved by your DNS servers to a IPv6 (AAAA record) | ||||||
| first, there are chances that your local router or ISP might have problem connecting to IPv6 networks. In that case | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Adding a reference to the relevant part of the fetch spec would be useful.
Uh oh!
There was an error while loading. Please reload this page.
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.
Would a link to this section suffice? If so I can address in a separate PR.
https://fetch.spec.whatwg.org/#cors-check