This commit is contained in:
@@ -31,7 +31,7 @@ const distDir = frontendDir + "/dist"
|
||||
const svelteConfig = require("./svelte.config")
|
||||
const esbuildSvelte = sveltePlugin({
|
||||
compilerOptions: {
|
||||
css: false,
|
||||
css: "external",
|
||||
hydratable: true,
|
||||
dev: (process.argv?.length > 2 ? process.argv[2] : "build") !== "build",
|
||||
},
|
||||
@@ -74,7 +74,8 @@ if (process.argv[2] == "start") {
|
||||
const TIBI_NAMESPACE = dotEnv.match(/TIBI_NAMESPACE=(.*)/)[1]
|
||||
const apiBase = process.env.API_BASE || "http://localhost:8080/api/v1/_/" + TIBI_NAMESPACE
|
||||
bsMiddleware.push(
|
||||
createProxyMiddleware("/api", {
|
||||
createProxyMiddleware({
|
||||
pathFilter: "/api",
|
||||
target: apiBase,
|
||||
pathRewrite: { "^/api": "" },
|
||||
changeOrigin: true,
|
||||
@@ -82,29 +83,20 @@ if (process.argv[2] == "start") {
|
||||
})
|
||||
)
|
||||
|
||||
// if SSR env variable is set
|
||||
console.log(process.env, "=========================ENV")
|
||||
if (process.env.SSR) {
|
||||
// read api/config.yml.env and read SSR_TOKEN variable from it
|
||||
const configEnv = fs.readFileSync(__dirname + "/api/config.yml.env", "utf8")
|
||||
const SSR_TOKEN = configEnv.match(/SSR_TOKEN=(.*)/)[1]
|
||||
|
||||
// redirect all other requests to /api/ssr?token=owshwerNwoa&url=...
|
||||
bsMiddleware.push(
|
||||
createProxyMiddleware(
|
||||
function (path, req) {
|
||||
createProxyMiddleware({
|
||||
pathFilter: function (path, req) {
|
||||
return !path.match(/\./)
|
||||
},
|
||||
{
|
||||
target: apiBase,
|
||||
changeOrigin: true,
|
||||
logLevel: "debug",
|
||||
pathRewrite: function (path, req) {
|
||||
console.log(path)
|
||||
return "/ssr?token=" + SSR_TOKEN + "&url=" + encodeURIComponent(path)
|
||||
},
|
||||
}
|
||||
)
|
||||
target: apiBase,
|
||||
changeOrigin: true,
|
||||
logLevel: "debug",
|
||||
pathRewrite: function (path, req) {
|
||||
console.log(path)
|
||||
return "/ssr?url=" + encodeURIComponent(path)
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user