Added wildcards for allowed hosts
This commit is contained in:
parent
526d7e04d7
commit
eb0d1ded1c
|
|
@ -1,27 +1,11 @@
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
const allowedHosts = [".develop.taylordb.ai", "localhost", "127.0.0.1"];
|
// https://vite.dev/config/
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [react()],
|
||||||
react(),
|
|
||||||
{
|
|
||||||
name: "host-validation",
|
|
||||||
configureServer(server) {
|
|
||||||
server.middlewares.use((req, res, next) => {
|
|
||||||
const host = req.headers.host?.split(":")[0];
|
|
||||||
if (host && allowedHosts.some((allowed) => host.endsWith(allowed))) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
res.writeHead(403, { "Content-Type": "text/plain" });
|
|
||||||
res.end(`Forbidden host: ${host}`);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
server: {
|
server: {
|
||||||
|
allowedHosts: [".develop.taylordb.ai", "localhost", "127.0.0.1"],
|
||||||
host: "0.0.0.0", // Listen on all network interfaces
|
host: "0.0.0.0", // Listen on all network interfaces
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user