Browse Source

Make proxying logic less ridiculous, use CRA to do it locally

Kirk Trombley 3 years ago
parent
commit
e9bc8e3b93

+ 8 - 0
README.md

@@ -148,6 +148,14 @@ POST /game/{game_id}/round/{round}/timeout/{player_id}
     }
 ```
 
+## Local Dev
+
+Change the proxy line in package.json to point to live server
+
+```json
+  "proxy": "https://hiram.services/",
+```
+
 ## Next Steps
 
 ### Planned Game Modes

+ 0 - 1
client/.env

@@ -1,3 +1,2 @@
-REACT_APP_API_BASE=https://hiram.services/terrassumptions/api
 REACT_APP_MONITOR_STORE=false
 REACT_APP_GOOGLE_API_KEY=AIzaSyCDtEWf192OYuMvd2cp8a04DYQo-RU_sXs

+ 0 - 2
client/.env.development.template

@@ -1,4 +1,2 @@
-# REACT_APP_API_BASE=http://localhost:5000
-# above can be uncommented to point to local server/app.py
 REACT_APP_MONITOR_STORE=true
 REACT_APP_GOOGLE_API_KEY=.

+ 1 - 0
client/package.json

@@ -31,6 +31,7 @@
     "eject": "react-scripts eject",
     "deploy": "scp -r build hiram:/opt/terrassumptions/srv/build-$(date +'%Y-%m-%dT%H:%M:%S')"
   },
+  "proxy": "http://localhost:5000/",
   "prettier": {
     "arrowParens": "avoid"
   },

+ 1 - 1
client/src/domain/apiMethods.js

@@ -1,4 +1,4 @@
-const API_BASE = process.env.REACT_APP_API_BASE;
+const API_BASE = "/terrassumptions/api";
 
 export const getStatus = async () => {
   try {

+ 1 - 1
server/Dockerfile

@@ -16,4 +16,4 @@ RUN pip3 install -r requirements.txt
 
 COPY ./app /app/app
 
-CMD uvicorn app:app --host 0.0.0.0 --port 5000 --root-path /terrassumptions/api
+CMD uvicorn app:app --host 0.0.0.0 --port 5000

+ 2 - 2
server/app/__init__.py

@@ -13,8 +13,8 @@ logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
 
 app = FastAPI()
 
-app.include_router(other)
-app.include_router(game, prefix="/game")
+app.include_router(other, prefix="/terrassumptions/api")
+app.include_router(game, prefix="/terrassumptions/api/game")
 
 
 app.add_middleware(