-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.mjs
52 lines (45 loc) · 1.31 KB
/
server.mjs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// const express = require('express');
// const { parse } = require('url');
// const proxy = require('http-proxy-middleware');
// const next = require('next');
import express from "express";
import next from "next";
import { createProxyMiddleware } from "http-proxy-middleware";
const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
const port = 3000;
// when using middleware `hostname` and `port` must be provided below
const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
const server = express();
server.use(
"/api",
createProxyMiddleware({
target: `${process.env.API_HOST || "http://localhost:8080"}`,
changeOrigin: true,
// ws: true
})
);
// server.use(
// "/api/chat",
// createProxyMiddleware({
// target: `${process.env.API_HOST || "http://localhost:8080"}`,
// changeOrigin: true,
// ws: true
// })
// );
// server.use(
// "/api/updates",
// createProxyMiddleware({
// target: `${process.env.API_HOST || "http://localhost:8080"}`,
// changeOrigin: true,
// ws: true
// })
// );
server.all("*", (req, res) => handle(req, res));
server.listen(port, () => {
console.log(`> Ready on http://${hostname}:${port}`);
});
});
export {};