Skip to content

Commit

Permalink
fix protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
seadfeng committed Aug 24, 2024
1 parent 0f62e96 commit b3a52f3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export const getOrigin = ({ headers }: { headers: Headers }) => {
const host = headers.get('host') || appConfig.appDomain;

const protocol = ['localhost', '127.0.0.1'].includes(host.split(":")[0]) ? 'http' : 'https';
return `${protocol}://${host}`;
const url = new URL(headers.get("x-request-url")!);
return `${url.protocol}://${url.host}`;
}

export const getCanonical = ({ headers }: { headers: Headers }) => {
const origin = getOrigin({ headers });
const url = new URL(headers.get("x-request-url")!);
return `${origin}${url.pathname}`;
return `${url.protocol}://${url.host}${url.pathname}`;
}

export const createAlternates = ({ headers }: { headers: Headers; }) => {
Expand Down

0 comments on commit b3a52f3

Please sign in to comment.