-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
35 lines (31 loc) · 999 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Connect, defineConfig, PluginOption } from 'vite';
import solidPlugin from 'vite-plugin-solid';
const forwardOrNext: Connect.NextHandleFunction = async (req, res, next) => {
if (req.originalUrl.startsWith('/server')) {
const response = await fetch('https://radekclicker.radeksoft.cz' + req.originalUrl, { method: req.method });
const resData = await response.text();
res.statusCode = response.status;
res.end(resData);
console.log('forwarded', req.method, response.status, req.originalUrl);
return;
}
next();
}
const httpForwardPlugin: PluginOption = {
name: 'http-forward',
configureServer(server) {
server.middlewares.use(forwardOrNext);
},
configurePreviewServer(server) {
server.middlewares.use(forwardOrNext);
}
};
export default defineConfig({
plugins: [solidPlugin(), httpForwardPlugin],
server: {
port: 3000,
},
build: {
target: 'esnext',
},
});