Skip to content

Commit f0a9dda

Browse files
committed
frontend: proxy live site
1 parent fa42a1b commit f0a9dda

File tree

3 files changed

+9
-39
lines changed

3 files changed

+9
-39
lines changed

internal/http/frontend/src/services/API.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,7 @@
1919

2020
import axios from 'axios';
2121

22-
let baseURL;
23-
24-
// nodejs development
25-
if (window.location.port == 5173) {
26-
// Change port to 3005
27-
baseURL = 'http://localhost:3005/api/v1';
28-
} else {
29-
baseURL = '/api/v1';
30-
}
22+
const baseURL = '/api/v1';
3123

3224
const instance = axios.create({
3325
baseURL,

internal/http/frontend/src/services/util.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ export function getWebsocketURI() {
2525
} else {
2626
newURI = 'ws:';
2727
}
28-
// nodejs development
29-
if (window.location.port == 5173) {
30-
// Change port to 3005
31-
newURI += '//' + loc.hostname + ':3005';
32-
} else {
33-
newURI += '//' + loc.host;
34-
}
35-
newURI += '/ws';
28+
newURI += '//' + loc.host + '/ws';
3629
console.log('Websocket URI: "' + newURI + '"');
3730
return newURI;
3831
}

internal/http/frontend/vite.config.js

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,14 @@ export default defineConfig({
1515
},
1616
server: {
1717
proxy: {
18-
'/api/v1/features': {
19-
bypass: (req, res) => {
20-
res.setHeader('Content-Type', 'application/json');
21-
res.end(JSON.stringify({ features: [''] }));
22-
},
18+
'/api': {
19+
target: 'https://dmrhub.net',
20+
changeOrigin: true,
2321
},
24-
'/api/v1/network/name': {
25-
bypass: (req, res) => {
26-
res.setHeader('Content-Type', 'text/plain');
27-
res.end('DMRHub');
28-
},
29-
},
30-
'/api/v1/me': {
31-
bypass: (req, res) => {
32-
res.setHeader('Content-Type', 'application/json');
33-
res.end(JSON.stringify({}));
34-
},
35-
},
36-
'/api/v1/version': {
37-
bypass: (req, res) => {
38-
res.setHeader('Content-Type', 'text/plain');
39-
res.end('Test');
40-
},
22+
'/ws': {
23+
target: 'wss://dmrhub.net',
24+
ws: true,
25+
changeOrigin: true,
4126
},
4227
},
4328
},

0 commit comments

Comments
 (0)