Skip to content

Commit ed9e208

Browse files
committed
Proxy development server requests to Express app
This allows you to use the Vite development server locally whilst still requesting resources from GCP buckets.
1 parent f347d31 commit ed9e208

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,43 @@ You can also configure the application locally by setting the following environm
8787
1. Open http://localhost:8080
8888

8989

90+
### Developing with Vite
91+
92+
When developing locally you may wish to use Vite to run the server locally for hot reloading.
93+
In order to ensure you can pull assets from GCP storage you will need to run the express app.
94+
95+
1. Authenticate with Google
96+
97+
```bash
98+
gcloud auth application-default login
99+
```
100+
101+
1. Run express app
102+
103+
```bash
104+
cd backend
105+
106+
GCS_BUCKET=dft-rlg-atip-dev USE_IAP=false npm start &
107+
```
108+
109+
1. Run Vite development server
110+
111+
```bash
112+
cd ..
113+
114+
npm run dev
115+
```
116+
117+
1. Open http://localhost:5173
118+
119+
1. After interrupting Vite tidy up the background Express app
120+
121+
```bash
122+
# presuming the job ID is 1
123+
# you can check this by running $ jobs
124+
kill %1
125+
```
126+
90127
## Usage
91128

92129
The development version is available for use at <https://acteng.github.io/atip>. Note this is not a production service and we make no guarantees about the site's uptime or about backwards compatibility of sketch files.

vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import wasmPack from "vite-plugin-wasm-pack";
55
import tsconfigPaths from "vite-tsconfig-paths";
66

77
export default defineConfig({
8+
server: {
9+
proxy: {
10+
"/data": "http://localhost:8080"
11+
}
12+
},
813
build: {
914
rollupOptions: {
1015
input: {

0 commit comments

Comments
 (0)