Skip to content

Commit f3e69f1

Browse files
committed
CMS: vercel urls
1 parent b8e7c34 commit f3e69f1

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use client";
2+
3+
const AuthHeader = () => {};
4+
5+
export default AuthHeader;

client/src/lib/url.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { env } from "@/env.mjs";
2+
3+
export const getAbsoluteURL = (path: string) => {
4+
if (process.env.VERCEL_URL) {
5+
return `https://${process.env.VERCEL_URL}${path}`;
6+
}
7+
8+
return `${env.NEXT_PUBLIC_URL || "http://localhost:3000"}${path}`;
9+
};

client/src/payload.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { lexicalEditor } from "@payloadcms/richtext-lexical";
99

1010
import sharp from "sharp";
1111

12-
import { env } from "@/env.mjs";
12+
import { getAbsoluteURL } from "@/lib/url";
1313

1414
import { Admins } from "@/cms/collections/Admins";
1515
import { Media } from "@/cms/collections/Media";
@@ -37,7 +37,7 @@ export default buildConfig({
3737
disable: true,
3838
},
3939
secret: process.env.PAYLOAD_SECRET || "",
40-
serverURL: env.NEXT_PUBLIC_URL,
40+
serverURL: getAbsoluteURL(""),
4141
typescript: {
4242
outputFile: path.resolve(dirname, "payload-types.ts"),
4343
},

client/src/services/sdk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { PayloadSDK } from "@payloadcms/sdk";
22

3+
import { getAbsoluteURL } from "@/lib/url";
4+
35
import { Config } from "@/payload-types";
46

57
// Pass your config from generated types as generic
68
export const sdk = new PayloadSDK<Config>({
7-
baseURL: `${process.env.NEXT_PUBLIC_URL}/api`,
9+
baseURL: getAbsoluteURL("/api"),
810
});

0 commit comments

Comments
 (0)