/forestry-game-frontend

Frontend app for https://github.com/nime88/forestry-game

Primary LanguageJavaScriptMIT LicenseMIT

forestry-game

Backend

https://github.com/nime88/forestry-game

Frontend

Setting up

  1. Install node.js if you don't have it (npm comes included)
  2. cd frontend
  3. npm install

Start development server

  1. cd frontend
  2. npm start
  3. Server starts at localhost:3000

The environment supports hot reloading, so the site automatically refreshes every time a file is changed.

Working with the backend

The frontend's package.json has a proxy setting in it:

"proxy": "http://localhost:8080"

This way, the frontend app automatically redirects requests to routes not found from it's own server to localhost:8080. So with the backend running at localhost:8080, requests in the frontend code to eg. /api/v1/give/me/stuff will be forwarded to the backend.

Building the frontend and integrating to backend

This is not neccessary in development, but the project is set up so that this should already work.

  1. cd frontend
  2. npm run build
  3. The whole frontend gets compiled into static files to build folder
  4. Move the contents of build folder to forestry_game/static
  5. Run Django app
  6. Go to localhost:8080

Result: The whole app, backend and frontend, running under the single Django server.