Skip to content

Commit 7063672

Browse files
committed
chore(frontend): QR code for dev --host and /api proxy
- Add vite-plugin-qrcode so `yarn dev --host` prints a scannable QR for the LAN URL. - Proxy /api to the backend in dev so the frontend can use same-origin relative URLs (VITE_API_URL=""), which keeps the dashboard reachable from other LAN devices instead of their own localhost.
1 parent 913be11 commit 7063672

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎frontend/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"typescript-eslint": "^8.60.1",
4646
"unplugin-auto-import": "^21.0.0",
4747
"vite": "^8.0.16",
48+
"vite-plugin-qrcode": "^0.4.1",
4849
"vite-tsconfig-paths": "^6.1.1",
4950
"vitest": "^4.1.8",
5051
"vitest-browser-react": "^2.2.0"

‎frontend/vite.config.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import react from "@vitejs/plugin-react";
22
import AutoImport from "unplugin-auto-import/vite";
33
import { defineConfig } from "vite";
4+
import { qrcode } from "vite-plugin-qrcode";
45

56
// https://vitejs.dev/config/
67
export default defineConfig({
8+
// Proxy API calls to the backend so the frontend can use same-origin relative
9+
// URLs (VITE_API_URL=""). This keeps `yarn dev --host` working from other LAN
10+
// devices — the request hits this dev server's IP and is forwarded here to the
11+
// backend on localhost, instead of the device trying its own localhost:3000.
12+
server: {
13+
proxy: {
14+
"/api": { target: "http://localhost:3000", changeOrigin: true },
15+
},
16+
},
717
plugins: [
818
react({
919
jsxImportSource: "@emotion/react",
@@ -15,5 +25,7 @@ export default defineConfig({
1525
imports: ["vitest"],
1626
dts: true,
1727
}),
28+
// Print a scannable QR code for the LAN URL with `yarn dev --host`.
29+
qrcode(),
1830
],
1931
});

‎frontend/yarn.lock‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4027,6 +4027,13 @@ __metadata:
40274027
languageName: node
40284028
linkType: hard
40294029

4030+
"uqr@npm:^0.1.2":
4031+
version: 0.1.3
4032+
resolution: "uqr@npm:0.1.3"
4033+
checksum: 10/cde1dd270e3d39fc1870375d33a88c1ec7ac430c6e1b0b28943ad08b029dc9409076aa2213ebf2eb209cfa37abccca365d85f2cd3b1cdefbcfb68ab8c18857d3
4034+
languageName: node
4035+
linkType: hard
4036+
40304037
"uri-js@npm:^4.2.2":
40314038
version: 4.4.1
40324039
resolution: "uri-js@npm:4.4.1"
@@ -4063,6 +4070,17 @@ __metadata:
40634070
languageName: node
40644071
linkType: hard
40654072

4073+
"vite-plugin-qrcode@npm:^0.4.1":
4074+
version: 0.4.1
4075+
resolution: "vite-plugin-qrcode@npm:0.4.1"
4076+
dependencies:
4077+
uqr: "npm:^0.1.2"
4078+
peerDependencies:
4079+
vite: ">=3"
4080+
checksum: 10/dd11488c2a038a4a6f7118e8eef5d825f3f3367c6ee2e0af432b2763eb2a83f104793b0376211d8cd7cb47866b8a191518477ba34f6c826e2820d700ba21e90c
4081+
languageName: node
4082+
linkType: hard
4083+
40664084
"vite-tsconfig-paths@npm:^6.1.1":
40674085
version: 6.1.1
40684086
resolution: "vite-tsconfig-paths@npm:6.1.1"
@@ -4220,6 +4238,7 @@ __metadata:
42204238
unplugin-auto-import: "npm:^21.0.0"
42214239
usehooks-ts: "npm:^3.1.1"
42224240
vite: "npm:^8.0.16"
4241+
vite-plugin-qrcode: "npm:^0.4.1"
42234242
vite-tsconfig-paths: "npm:^6.1.1"
42244243
vitest: "npm:^4.1.8"
42254244
vitest-browser-react: "npm:^2.2.0"

0 commit comments

Comments
 (0)