♻️ Avoid getServerSideProps for login/register (#755)

This commit is contained in:
Luke Vella 2023-07-14 18:09:14 +01:00 committed by GitHub
parent becc7a7930
commit 438c4ec35b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 98 additions and 197 deletions

View file

@ -6,17 +6,25 @@ const getVercelUrl = () => {
: null;
};
function joinPath(baseUrl: string, subpath = "") {
if (subpath) {
const url = new URL(subpath, baseUrl);
return url.href;
}
return baseUrl;
}
export function absoluteUrl(subpath = "") {
const baseUrl =
process.env.NEXT_PUBLIC_BASE_URL ??
getVercelUrl() ??
`http://localhost:${port}`;
const url = new URL(subpath, baseUrl);
return url.href;
return joinPath(baseUrl, subpath);
}
export function shortUrl(subpath = "") {
const baseUrl = process.env.NEXT_PUBLIC_SHORT_BASE_URL ?? absoluteUrl();
const url = new URL(subpath, baseUrl);
return url.href;
return joinPath(baseUrl, subpath);
}