Skip to content

Commit

Permalink
get origin var from env
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmol committed Oct 2, 2023
1 parent 5efacea commit 84670f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const server = new Server(manifest);
await server.init({ env: (Bun || process).env });

const xff_depth = parseInt(env("XFF_DEPTH", build_options.xff_depth ?? 1));
const origin = env('ORIGIN', undefined);

const address_header = env("ADDRESS_HEADER", "").toLowerCase();
const protocol_header = env("PROTOCOL_HEADER", "X-Forwarded-Proto").toLowerCase();
Expand Down Expand Up @@ -97,8 +98,8 @@ function ssr(req) {
if (build_options.dynamic_origin ?? false) {
let url = req.url;
let path = url.slice(url.split("/", 3).join("/").length);
let origin = get_origin(req.headers);
request = new Request(origin + path, req);
let base = origin || get_origin(req.headers);
request = new Request(base + path, req);
}

if (address_header && !request.headers.has(address_header)) {
Expand Down

0 comments on commit 84670f9

Please sign in to comment.