Skip to content

Commit

Permalink
fix: use X-Real-Origin after homepage redirect discard
Browse files Browse the repository at this point in the history
  • Loading branch information
esroyo committed Nov 16, 2023
1 parent 15ee70e commit 15d26e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/esm-proxy-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export async function esmProxyRequestHandler(
REDIRECT_FAILURE_CACHE,
} = await resolveConfig();
const selfUrl = new URL(req.url);
const realUrl = new URL(req.headers.get('X-Real-Origin') ?? selfUrl);
const basePath = `/${BASE_PATH}/`.replace(/\/+/g, '/');
const esmOrigin = `${ESM_ORIGIN}/`.replace(/\/+$/, '/');
if (selfUrl.pathname === `${basePath}`) {
return Response.redirect(HOMEPAGE || esmOrigin, 302);
}
const realUrl = new URL(req.headers.get('X-Real-Origin') ?? selfUrl);
const selfOrigin = `${realUrl.origin}${basePath}`;
const esmUrl = new URL(req.url.replace(selfOrigin, ''), esmOrigin);
const replaceOrigin = (() => {
Expand Down

0 comments on commit 15d26e6

Please sign in to comment.