5

Sec-Fetch-Mode

 3 years ago
source link: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Mode
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Sec-Fetch-Mode

The Sec-Fetch-Mode fetch metadata request header indicates the mode of the request.

Broadly speaking, this allows a server to distinguish between: requests originating from a user navigating between HTML pages, and requests to load images and other resources. For example, this header would contain navigate for top level navigation requests, while no-cors is used for loading an image.

Syntax

Sec-Fetch-Mode: cors
Sec-Fetch-Mode: navigate
Sec-Fetch-Mode: no-cors
Sec-Fetch-Mode: same-origin
Sec-Fetch-Mode: websocket

Servers should ignore this header if it contains any other value.

Directives

These directives correspond to the values in Request.mode.

cors The request is a CORS protocol request. navigate The request is initiated by navigation between HTML documents. no-cors The request is a no-cors request (see Request.mode). same-origin The request is made from the same origin as the resource that is being requested. websocket The request is being made to establish a WebSocket connection.

Examples

If a user clicks on a page link to another page on the same origin, the resulting request would have the following headers (note that the mode is navigate):

Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1

A cross-site request generated by an <img> element would result in a request with the following HTTP request headers (note that the mode is no-cors):

Sec-Fetch-Dest: image
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: cross-site

Specifications

SpecificationFetch Metadata Request Headers (Fetch Metadata)
# sec-fetch-mode-header

Browser compatibility

Report problems with this compatibility data on GitHubdesktopmobileChromeEdgeFirefoxInternet ExplorerOperaSafariWebView AndroidChrome AndroidFirefox for AndroidOpera AndroidSafari on iOSSamsung Internet
Sec-Fetch-Mode
Full support76Full support79Full support90No supportNoFull support63No supportNoFull support76Full support76Full support90Full support54No supportNoFull support12.0

Legend

Full supportFull support
No supportNo support

See also


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK