From 66a2ef2260c2f2ea3359a774c384255c14d371c7 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Thu, 2 Jun 2022 15:58:44 +0000 Subject: [PATCH] add proxy for api in dev so it works in codespaces hopefully didn't break anything --- README.md | 4 ++++ frontend/.proxyrc | 8 ++++++++ frontend/src/env.ts | 11 +++++------ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 frontend/.proxyrc diff --git a/README.md b/README.md index b3a3743..3734a66 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ docker-compose example in `dockercomposeexample` folder * `HTTPS` (`"yes"`/`"no"`) - whether the server enforce HTTPS or not +* `API_ROOT` + +* `WEB_ROOT` + ### Additional config options if you're not using docker * `DATA_DIR` - data directory for photos and uploaded files diff --git a/frontend/.proxyrc b/frontend/.proxyrc new file mode 100644 index 0000000..40218af --- /dev/null +++ b/frontend/.proxyrc @@ -0,0 +1,8 @@ +{ + "/api": { + "target": "http://localhost:3000/", + "pathRewrite": { + "^/api": "" + } + } +} diff --git a/frontend/src/env.ts b/frontend/src/env.ts index d9bd20a..407777f 100644 --- a/frontend/src/env.ts +++ b/frontend/src/env.ts @@ -1,12 +1,11 @@ export const apiRoot = process.env.API_ROOT || - process.env.NODE_ENV === "production" || - !process.env.NODE_ENV + (!process.env.NODE_ENV || process.env.NODE_ENV === "production" ? window.location.origin - : "http://localhost:3000"; + : process.env.NODE_ENV === "development" && + window.location.origin + "/api"); export const webRoot = process.env.WEB_ROOT || - process.env.NODE_ENV === "production" || - !process.env.NODE_ENV + (!process.env.NODE_ENV || process.env.NODE_ENV === "production" ? window.location.origin - : "http://localhost:1234"; + : "http://localhost:1234");