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
environment:
- INTERNAL_AUTH_URL=http://api_server:8080
- INTERNAL_URL=http://api_server:8080
- NODE_ENV=development
ports:
- "3000:3000"
relational_db:

View File

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

View File

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

View File

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

View File

@ -1 +1,2 @@
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 { User } from "./types";
const INTERNAL_AUTH_URL =
process.env.INTERNAL_AUTH_URL || "http://127.0.0.1:8080";
import { INTERNAL_URL } from "./constants";
export const buildUrl = (path: string) => {
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> => {