Skip to content

Commit 29dd37b

Browse files
committed
add dev mode conditionals
1 parent 1e60623 commit 29dd37b

File tree

7 files changed

+51
-30
lines changed

7 files changed

+51
-30
lines changed

backend/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import './env.js'
77

88

99
var corsOptions = {
10-
// origin: 'https://10.0.0.124:5173',
11-
origin: 'https://lookatme.earth'
10+
origin: process.env.NODE_ENV === 'development' ? 'https://10.0.0.124:5173' : 'https://lookatme.earth'
1211
}
1312

1413
const limiter = rateLimit({
@@ -23,7 +22,7 @@ const router = new Router();
2322

2423
app.use(router);
2524

26-
const port = 5007
25+
const port = process.env.NODE_ENV === 'development' ? 3000 : 5007
2726

2827
const API_KEY = process.env.NOAA_DECLINATION_API_KEY;
2928

backend/env.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
import { config } from 'dotenv';
2-
config({ path: new URL('/app/variables/.env', import.meta.url).pathname });
2+
if (process.env.NODE_ENV !== 'development') {
3+
config({ path: new URL('/app/variables/.env', import.meta.url).pathname });
4+
}

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "npx tsc",
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"dev": "npx tsx watch app.ts"
9+
"dev": "NODE_ENV=development npx tsx watch app.ts"
1010
},
1111
"author": "",
1212
"license": "ISC",

frontend/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite --host",
7+
"dev": "NODE_ENV=development vite --host",
88
"build": "vue-tsc && vite build",
99
"preview": "vite preview"
1010
},
@@ -18,6 +18,7 @@
1818
"vue": "^3.4.21"
1919
},
2020
"devDependencies": {
21+
"@types/node": "^24.0.10",
2122
"@vitejs/plugin-vue": "^5.0.4",
2223
"typescript": "^5.2.2",
2324
"vite": "^5.2.0",

frontend/src/components/Home.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const partnerBearing = ref<number>(0);
3939
const backgroundClasses = ref<string>();
4040
const roomId = ref<string>();
4141
42-
const { status, data, send, open } = useWebSocket('wss://api.lookatme.earth/realtime', {
42+
const { status, data, send, open } = useWebSocket(import.meta.env.DEV ? 'wss://10.0.0.124:5173/realtime' : 'wss://api.lookatme.earth/realtime', {
4343
immediate: false,
4444
});
4545
@@ -87,7 +87,7 @@ const obtainRoughLocation = async () => {
8787
}
8888
8989
const obtainDeclination = async (): Promise<number> => {
90-
const { data } = await axios.get(`https://api.lookatme.earth/declination`, {
90+
const { data } = await axios.get(import.meta.env.DEV ? '/api/declination' : 'https://api.lookatme.earth/declination', {
9191
params: {
9292
latitude: roughLocation.value?.latitude,
9393
longitude: roughLocation.value?.longitude,

frontend/vite.config.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
33
import tailwindcss from '@tailwindcss/vite'
44
import { fileURLToPath } from 'url';
5-
// import fs from 'fs';
5+
import fs from 'fs';
66

77
// https://vitejs.dev/config/
88
export default defineConfig({
@@ -13,28 +13,29 @@ export default defineConfig({
1313
}
1414
},
1515
server: {
16-
// TODO: Remove this
17-
// https: {
18-
// key: fs.readFileSync('key.pem'),
19-
// cert: fs.readFileSync('cert.pem')
20-
// },
16+
https: {
17+
...(process.env.NODE_ENV === 'development' ? {
18+
key: fs.readFileSync('key.pem'),
19+
cert: fs.readFileSync('cert.pem')
20+
} : {})
21+
},
2122
proxy: {
22-
// HTTP API proxy
23-
// '/api': {
24-
// // target: 'http://10.0.0.124:3000',
25-
// target: 'https://api.lookatme.earth',
26-
// changeOrigin: true,
27-
// secure: false,
28-
// rewrite: (path) => path.replace(/^\/api/, ''),
29-
// },
30-
// WebSocket proxy
31-
// '/realtime': {
32-
// // target: 'ws://10.0.0.124:3000',
33-
// target: 'ws://lookatme.earth',
34-
// ws: true,
35-
// changeOrigin: true,
36-
// secure: false,
37-
// }
23+
...(process.env.NODE_ENV === 'development' ? {
24+
// HTTP API proxy
25+
'/api': {
26+
target: 'http://10.0.0.124:3000',
27+
changeOrigin: true,
28+
secure: false,
29+
rewrite: (path) => path.replace(/^\/api/, ''),
30+
},
31+
// WebSocket proxy
32+
'/realtime': {
33+
target: 'ws://10.0.0.124:3000',
34+
ws: true,
35+
changeOrigin: true,
36+
secure: false,
37+
}
38+
} : {})
3839
}
3940
}
4041
})

0 commit comments

Comments
 (0)