diff --git a/README.md b/README.md index 3dba4aed5..f45f3234f 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,36 @@ found at [api.laji.fi](https://apitest.laji.fi/explorer/). This repo contains 3 main branches. Follow guidelines set in [wiki](http://wiki.helsinki.fi/display/luomusict/Laji.fi+front+kehitysohjeet) for developing. ## Development server -```bash -# clone branch -git clone git@github.com:luomus/laji.git -cd laji +### Installation + +Make sure to use the correct node version marked in `.nvmrc`. You can use for example volta or nvm. -# Install application dependencies -# Redis and make sure that it's running -# Python and maker sure that the python executable is in the path +Install the dependencies: -# Install js dependencies (node >= v14) +```bash npm ci +``` + +### Running -# Run the environment +```bash npm start +``` + +Go with your browser to http://localhost:3000/ + +### API proxy configuration -# Go with your browser to http://localhost:3000/ +By default the app proxies api requests through https://dev.laji.fi/api. You can configure the api base and the access token with `.env` file: + +``` +API_BASE=https://apitest.laji.fi +ACCESS_TOKEN= ``` ## Running end-to-end tests -1. Create an empty `.env` file at the root of the repository: +1. Add the following to `.env` file at the root of the repository: ``` E2E_PERSON_TOKEN= E2E_USER= diff --git a/config.json b/config.json deleted file mode 100644 index 20cd2e829..000000000 --- a/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "api_base": "https://apitest.laji.fi", - "access_token": "SBL3mE8FhECAWMIuJCPDQsFhLPoz4uhr9drid11nGsOMXECaAe7m5s9ptGo0UWzo" -} diff --git a/proxy.conf.js b/proxy.conf.js index fbd25b730..574088dd8 100644 --- a/proxy.conf.js +++ b/proxy.conf.js @@ -1,21 +1,21 @@ -const config = require('./config'); +require('dotenv').config(); -module.exports = { - '/api/**': { - target: config.api_base, - changeOrigin: true, - xfwd: true, - secure: false, - pathRewrite: { - '^/api/': 'v0/' - }, - headers: { - Authorization: config.access_token - }, - rewrite: function(req) { - req.url = req.url.replace(/^\/api/, 'v0') + - (req.url.indexOf('?') === -1 ? '?' : '&' ) + - 'access_token=' + config.access_token; - } +const proxyConfig = { + target: process.env.API_BASE || "https://dev.laji.fi/api", + changeOrigin: true, + xfwd: true, + secure: false, + pathRewrite: { + '^/api/': 'v0/' + } +}; + +if (process.env.ACCESS_TOKEN) { + proxyConfig.headers = { + Authorization: process.env.ACCESS_TOKEN } +} + +module.exports = { + '/api/**': proxyConfig };