The Origin header is:
This is not the ip or hostname of the client that created the request to the server
The Origin header value is the same than the Referer header but without the path.
A devtool network snaphost of a request showing that this is a request created by a code that originates from fiddle.jshell.net to datacadamia.com
When the browser add the origin header.
Browser | Request Type | Origin Added ? |
---|---|---|
All browser | Cross-origin | Yes |
Chrome | Same-origin | Yes: POST/PUT/DELETE No: GET/HEAD |
Safari | Same-origin | Yes: POST/PUT/DELETE No: GET/HEAD |
An origin is calculated by the browser with the scheme, host, and port of a URL of the request that created the resource (page, script)
If you want to set the origin what you want to do is mainly to set the host header on the web server.
console.log(`The origin of this page is ${window.origin}`)