Fix dev setup

This commit is contained in:
Weves
2023-05-17 15:48:46 -07:00
committed by Chris Weaver
parent 25d12ea604
commit bdebb9d441
6 changed files with 25 additions and 22 deletions

View File

@@ -42,7 +42,8 @@ services:
env_file: env_file:
- .env - .env
environment: environment:
- INTERNAL_AUTH_URL=http://api_server:8080 - INTERNAL_URL=http://api_server:8080
- NODE_ENV=development
ports: ports:
- "3000:3000" - "3000:3000"
relational_db: relational_db:

View File

@@ -40,7 +40,8 @@ services:
env_file: env_file:
- .env - .env
environment: environment:
- INTERNAL_AUTH_URL=http://api_server:8080 - INTERNAL_URL=http://api_server:8080
- NODE_ENV=production
relational_db: relational_db:
image: postgres:15.2-alpine image: postgres:15.2-alpine
restart: always restart: always

View File

@@ -31,7 +31,9 @@ RUN npm run build
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV production # Not needed, set by compose
# ENV NODE_ENV production
# Disable automatic telemetry collection # Disable automatic telemetry collection
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1

View File

@@ -5,20 +5,20 @@ const nextConfig = {
}, },
output: "standalone", output: "standalone",
redirects: async () => { redirects: async () => {
// In production, something else (nginx in the one box setup) takes care // In production, something else (nginx in the one box setup) should take
// of this redirect // care of this redirect. Leaving in for now due to issues with dev setup
// NOTE: this may get adjusted later if we want to support hosting of the // and accessing `process.env.NODE_ENV` + for cases where people don't want
// API server on a different domain without requring some kind of proxy // to setup nginx and are okay with the frontend proxying the request.
if (process.env.NODE_ENV === "development") { // TODO (chris): better support non-nginx setups
return [ return [
{ {
source: "/api/:path*", source: "/api/:path*",
destination: "http://localhost:8080/:path*", // Proxy to Backend destination: `${
process.env.INTERNAL_URL || "http://localhost:8080"
}/:path*`, // Proxy to Backend
permanent: true, permanent: true,
}, },
]; ];
}
return [];
}, },
}; };

View File

@@ -1 +1,2 @@
export const DISABLE_AUTH = process.env.DISABLE_AUTH?.toLowerCase() === "true"; export const DISABLE_AUTH = process.env.DISABLE_AUTH?.toLowerCase() === "true";
export const INTERNAL_URL = process.env.INTERNAL_URL || "http://127.0.0.1:8080";

View File

@@ -1,14 +1,12 @@
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { User } from "./types"; import { User } from "./types";
import { INTERNAL_URL } from "./constants";
const INTERNAL_AUTH_URL =
process.env.INTERNAL_AUTH_URL || "http://127.0.0.1:8080";
export const buildUrl = (path: string) => { export const buildUrl = (path: string) => {
if (path.startsWith("/")) { if (path.startsWith("/")) {
return `${INTERNAL_AUTH_URL}${path}`; return `${INTERNAL_URL}${path}`;
} }
return `${INTERNAL_AUTH_URL}/${path}`; return `${INTERNAL_URL}/${path}`;
}; };
export const getGoogleOAuthUrlSS = async (): Promise<string> => { export const getGoogleOAuthUrlSS = async (): Promise<string> => {