From e74860d310ba18d4b1524c8a176269a37ffafa5e Mon Sep 17 00:00:00 2001 From: Kirill Korsun Date: Wed, 1 May 2024 14:58:12 +0200 Subject: [PATCH] fix: add api env variable (#9) (#10) * fix: add api env variable * fix: add yml env --- .env | 3 +++ .env.example | 3 +++ .github/workflows/dry-run.yml | 1 + client/src/api/fetchRoute.ts | 2 +- server/src/server.ts | 8 +++----- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 683e13e..293ea53 100644 --- a/.env +++ b/.env @@ -3,3 +3,6 @@ OPENROUTESERVICE_API_KEY='5b3ce3597851110001cf62481766f58b063741c9977ec6ce848a72 GEOAPIFY_API_KEY='c9d16928a77b4f1185aff845ae4e73da' THUNDERFOREST_API_KEY='7d9fefffc2984231af5a54c5e4ad0a83' MAPTILER_API_KEY='ldgujGplx520Q0a3WG1f' + +# API_BASE_URL='https://roamus-server.vercel.app' +API_BASE_URL='http://localhost:4000' diff --git a/.env.example b/.env.example index 6b0fbc8..33ac2a2 100644 --- a/.env.example +++ b/.env.example @@ -12,3 +12,6 @@ THUNDERFOREST_API_KEY= # https://cloud.maptiler.com/maps MAPTILER_API_KEY= + +# https://roamus-server.vercel.app +API_BASE_URL='https://localhost:4000' diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml index fe1d5ad..9c5bdc1 100644 --- a/.github/workflows/dry-run.yml +++ b/.github/workflows/dry-run.yml @@ -31,6 +31,7 @@ jobs: GEOAPIFY_API_KEY: ${{ secrets.GEOAPIFY_API_KEY }} THUNDERFOREST_API_KEY: ${{ secrets.THUNDERFOREST_API_KEY }} MAPTILER_API_KEY: ${{ secrets.MAPTILER_API_KEY }} + API_BASE_URL: ${{ secrets.API_BASE_URL }} - name: Lint run: yarn lint diff --git a/client/src/api/fetchRoute.ts b/client/src/api/fetchRoute.ts index 0b3e2e1..6eeefad 100644 --- a/client/src/api/fetchRoute.ts +++ b/client/src/api/fetchRoute.ts @@ -4,7 +4,7 @@ import { apiService } from '@/services'; export const fetchRoute = async (payload: ProxyServerPayload) => { return apiService.post({ - url: 'http://localhost:4000/api/routing', + url: `${process.env.API_BASE_URL}/api/routing`, payload, }); }; diff --git a/server/src/server.ts b/server/src/server.ts index e68482c..579be55 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -17,11 +17,9 @@ app.get('/', (_, res) => { app.use(errorHandler); -app.set('port', 4000); +const PORT = process.env.PORT || 4000; -app.listen(app.get('port'), () => +app.listen(PORT, () => // eslint-disable-next-line no-console - console.log( - `${'\u001b[1;34m'}Server listening on port ${app.get('port')} 🚀🚀🚀`, - ), + console.log(`${'\u001b[1;34m'}Server listening on port ${PORT} 🚀🚀🚀`), );