Mohan
Mohan
CDCloudflare Developers
Created by Mohan on 6/12/2023 in #workers-help
how to find the origin of the incoming request
Not the url origin! But the origin of the web request from which the request is being made. "The "Origin" header in HTTP refers to the origin of a web request, which indicates the scheme (protocol), domain, and port from which the request is being made. It provides information about the source of the request and is primarily used as a security mechanism in the context of cross-origin resource sharing (CORS)." In Node.js we can get the origin by
const http = require('http');

const server = http.createServer((req, res) => {
const origin = req.headers.origin;
});
const http = require('http');

const server = http.createServer((req, res) => {
const origin = req.headers.origin;
});
5 replies