-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
37 lines (34 loc) · 1014 Bytes
/
vite.config.js
File metadata and controls
37 lines (34 loc) · 1014 Bytes
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
setupMiddlewares(middlewares, devServer) {
middlewares.use("/set-cookie", (req, res) => {
const url = new URL(req.url, `http://${req.headers.host}`);
const key = url.searchParams.get("key") || "myKey";
const value = url.searchParams.get("value") || "myValue";
res.writeHead(200, {
"Content-Type": "text/plain",
"Set-Cookie": `${key}=${value}; Path=/`,
});
res.end(`Cookie ${key}=${value} set ✅`);
});
return middlewares;
},
proxy: {
"/api": {
target: "http://localhost:8001/",
changeOrigin: true,
secure: false,
},
},
allowedHosts: [
"https://35461e231d364d2f4b5ebdd41e93ddfc.serveo.net",
"ebf67a73233a7aec77610636841d8326.serveo.net",
],
host: true,
port: 5173,
},
});