Skip to content

Commit

Permalink
rerename SERVER_URL, update missing variables to docker-compose .env
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jan 20, 2024
1 parent 79d4900 commit bfe3c8d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .env.docker-compose.prod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ PAYLOAD_PORT=3001
NEXT_REVALIDATION_KEY="veryprivatekey"

PUBLIC_FRONTEND_URL="http://localhost:3000"
SERVER_URL="http://cms:3001"
PUBLIC_SERVER_URL="http://cms:3001"
PUBLIC_ILMOMASIINA_URL="https://ilmo.tietokilta.fi"
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PAYLOAD_PUBLIC_LOCAL_DEVELOPMENT=true
NEXT_REVALIDATION_KEY="veryprivatekey"

PUBLIC_FRONTEND_URL="http://localhost:3000"
SERVER_URL="http://localhost:3001"
PUBLIC_SERVER_URL="http://localhost:3001"
PUBLIC_ILMOMASIINA_URL="https://ilmo.tietokilta.fi"

# variables required for Google OAuth 2.0, otherwise disabled
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const {

export default buildConfig({
// TODO: should probably enable this for production but it breaks auth in development
// serverURL: process.env.SERVER_URL,
// serverURL: process.env.PUBLIC_SERVER_URL,
admin: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- stupid eslint doesn't find the type
bundler: webpackBundler(),
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/next_api/preview/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function GET(
}

// validate the Payload token
const userReq = await fetch(`${process.env.SERVER_URL}/api/users/me`, {
const userReq = await fetch(`${process.env.PUBLIC_SERVER_URL}/api/users/me`, {
headers: {
Authorization: `JWT ${payloadToken}`,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/admin-bar-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function AdminBarClient({
return (
<PayloadAdminBar
className="bottom-0"
cmsURL={process.env.SERVER_URL ?? window.location.origin}
cmsURL={process.env.PUBLIC_SERVER_URL ?? window.location.origin}
collection={collection}
id={id}
onPreviewExit={void exitPreview}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/lib/api/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getAll = <
(req) => `get_${path}_${stringify(req)}`,
async (req, draft, fetchOptions): Promise<Response | undefined> => {
const result = await fetch(
`${process.env.SERVER_URL}${path}?${qsStringify({
`${process.env.PUBLIC_SERVER_URL}${path}?${qsStringify({
...req,
...(draft ? { draft: "true" } : {}),
}).toString()}`,
Expand All @@ -81,7 +81,7 @@ export const getGlobal = <Response>(path: string, locale?: string) =>
() => `getGlobal_${path}`,
async (_, draft, fetchOptions): Promise<Response | undefined> => {
const result = await fetch(
`${process.env.SERVER_URL}${path}?${qsStringify({
`${process.env.PUBLIC_SERVER_URL}${path}?${qsStringify({
depth: 10, // TODO: remove this when we have a better way to handle depth for example with GraphQL
// Needs to be bigger than 1 to get media / images
...(draft ? { draft: "true" } : {}),
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function middleware(request: NextRequest): NextResponse {
pathname.startsWith("/api") ||
pathname.startsWith("/oauth2")
) {
const destination = new URL(process.env.SERVER_URL || "");
const destination = new URL(process.env.PUBLIC_SERVER_URL || "");
const url = request.nextUrl.clone();
url.host = destination.host;
url.port = destination.port;
Expand Down
1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
context: .
args:
- PROJECT=web
- GIT_COMMIT_SHA=test
depends_on:
- cms
env_file:
Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"PAYLOAD_PUBLIC_LOCAL_DEVELOPMENT",
"NEXT_REVALIDATION_KEY",
"PUBLIC_FRONTEND_URL",
"SERVER_URL",
"PUBLIC_SERVER_URL",
"PUBLIC_ILMOMASIINA_URL"
],
"pipeline": {
Expand Down

0 comments on commit bfe3c8d

Please sign in to comment.