From 9ad8b5cc2cd2c2f4cb177c4579a9e98d79456483 Mon Sep 17 00:00:00 2001 From: solufa Date: Sun, 9 Jun 2024 04:18:14 +0900 Subject: [PATCH] refactor: remove API_ORIGIN from env --- Dockerfile | 9 +++------ client/aspida.config.js | 6 ------ client/package-lock.json | 13 ------------- client/package.json | 1 - client/utils/apiClient.ts | 3 ++- server/.env.example | 1 - 6 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 client/aspida.config.js diff --git a/Dockerfile b/Dockerfile index 8c771ce..a30286d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ COPY . . ARG SERVER_PORT=5000 ARG VERSION -ARG API_ORIGIN=http://localhost:$SERVER_PORT ARG NEXT_PUBLIC_COGNITO_POOL_ENDPOINT=http://localhost:$SERVER_PORT ARG NEXT_PUBLIC_COGNITO_POOL_ID=ap-northeast-1_randomPoolId ARG NEXT_PUBLIC_COGNITO_CLIENT_ID=random-client-id @@ -28,12 +27,10 @@ FROM node:20-alpine WORKDIR /usr/src/app -ARG SERVER_PORT=5000 ARG CLIENT_PORT=5001 -ENV PORT=$SERVER_PORT +ENV PORT=5000 ENV CLIENT_PORT=$CLIENT_PORT -ENV API_ORIGIN=http://localhost:$SERVER_PORT ENV CORS_ORIGIN=http://localhost:$CLIENT_PORT ENV DATABASE_URL=file:../../data/app.db ENV SMTP_HOST=inbucket @@ -53,9 +50,9 @@ COPY --from=builder /usr/src/app/server/prisma ./server/prisma RUN apk --no-cache add curl COPY --from=builder /usr/src/app/data ./data -HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f $API_ORIGIN/health && curl -f $CORS_ORIGIN || exit 1 +HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f http://localhost:$PORT/health && curl -f $CORS_ORIGIN || exit 1 -EXPOSE ${SERVER_PORT} ${CLIENT_PORT} +EXPOSE ${PORT} ${CLIENT_PORT} VOLUME ["/usr/src/app/data"] CMD ["npm", "start"] diff --git a/client/aspida.config.js b/client/aspida.config.js deleted file mode 100644 index 1502774..0000000 --- a/client/aspida.config.js +++ /dev/null @@ -1,6 +0,0 @@ -require('dotenv').config({ path: '../server/.env' }); - -module.exports = { - input: '../server/api', - baseURL: process.env.API_ORIGIN, -}; diff --git a/client/package-lock.json b/client/package-lock.json index 8d6643d..bfb64dd 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -21,7 +21,6 @@ "devDependencies": { "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", - "dotenv": "^16.4.5", "happy-css-modules": "^2.1.2", "notios": "^0.4.1", "pathpida": "^0.22.0" @@ -3713,18 +3712,6 @@ "tslib": "^2.0.3" } }, - "node_modules/dotenv": { - "version": "16.4.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", - "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", diff --git a/client/package.json b/client/package.json index 2434a1b..c7f0578 100644 --- a/client/package.json +++ b/client/package.json @@ -36,7 +36,6 @@ "devDependencies": { "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", - "dotenv": "^16.4.5", "happy-css-modules": "^2.1.2", "notios": "^0.4.1", "pathpida": "^0.22.0" diff --git a/client/utils/apiClient.ts b/client/utils/apiClient.ts index f387413..04ab05b 100644 --- a/client/utils/apiClient.ts +++ b/client/utils/apiClient.ts @@ -1,5 +1,6 @@ import aspida from '@aspida/axios'; import api from 'api/$api'; import axios from 'axios'; +import { NEXT_PUBLIC_COGNITO_POOL_ENDPOINT } from './envValues'; -export const apiClient = api(aspida(axios.create({ withCredentials: true }))); +export const apiClient = api(aspida(axios.create({ baseURL: NEXT_PUBLIC_COGNITO_POOL_ENDPOINT }))); diff --git a/server/.env.example b/server/.env.example index 8095998..14c6cde 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,6 +1,5 @@ PORT=5000 CLIENT_PORT= -API_ORIGIN=http://localhost:5000 CORS_ORIGIN=http://localhost:5001 DATABASE_URL=file:../../data/app.db TEST_DATABASE_URL=file:../../data/test.db