Skip to content

Commit

Permalink
Migrate override of BACKEND_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
henrist committed Jul 18, 2024
1 parent 0ff054f commit 2449294
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,34 @@ For å gjøre lokal utvikling trenger du:

### Kjøre frontend lokalt

Frontend kan utvikles direkte mot backend i produksjon. Tilpass `BACKEND_URL`
etter hva du ønsker å gå mot.

1. ```bash
cd frontend
```

1. Installer/oppdater avhengigheter:
2. Installer/oppdater avhengigheter:

```bash
npm ci
```

1. Kjør lokal server

enten mot lokalt:
3. Kjør lokal server

```bash
BACKEND_URL=http://localhost:8081/ npx ng servce --port 3000 --open
npx ng serve --port 3000 --open
```

eller mot produksjon:
Denne går mot lokal backend som standard.
For å gå mot produksjon kan man kjøre følgende i nettleser-konsollen (og oppdater siden):

```bash
BACKEND_URL=https://billett.blindernuka.no/ npx ng servce --port 3000 --open
```js
localStorage.setItem("billett-baseurl", "https://billett.blindernuka.no/")
```

Og for å endre tilbake:

```js
localStorage.removeItem("billett-baseurl")
### phpMyAdmin
Kan brukes for å enkelt se og gjøre manuelle endringer i den lokale databasen.
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// TODO(migrate): Support BACKEND_URL env override.
const BACKEND_URL = "/"

export let backendUrl = BACKEND_URL
export let backendUrl = localStorage.getItem("billett-baseurl") ?? "/"

if (backendUrl.includes("SAMEHOST")) {
backendUrl = backendUrl.replace("SAMEHOST", window.location.hostname)
Expand Down
18 changes: 0 additions & 18 deletions frontend/vite.config.ts

This file was deleted.

0 comments on commit 2449294

Please sign in to comment.