feat(frontend): migrated old > new silo adjustments
moved the apps around so we can use 1 url for cors bs
This commit is contained in:
28
app/main.ts
28
app/main.ts
@@ -4,6 +4,7 @@ import { toNodeHandler } from "better-auth/node";
|
||||
import cors from "cors";
|
||||
import express from "express";
|
||||
import { createServer } from "http";
|
||||
import { createProxyMiddleware, fixRequestBody } from "http-proxy-middleware";
|
||||
import morgan from "morgan";
|
||||
import os from "os";
|
||||
import { dirname, join } from "path";
|
||||
@@ -81,6 +82,24 @@ const main = async () => {
|
||||
);
|
||||
}
|
||||
|
||||
// old app prox temp stuff
|
||||
app.use(
|
||||
basePath + "/old",
|
||||
createProxyMiddleware({
|
||||
target: `http://localhost:3000`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: (path, req) => {
|
||||
// Remove the basePath + '/old' prefix from the path dynamically
|
||||
return path.replace(`${basePath}/old`, "");
|
||||
},
|
||||
|
||||
headers: {
|
||||
// forward auth headers if needed
|
||||
"X-Forwarded-By": "express-proxy",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// global middleware
|
||||
app.set("trust proxy", true);
|
||||
app.use(apiHitMiddleware);
|
||||
@@ -93,6 +112,8 @@ const main = async () => {
|
||||
/^https?:\/\/.*\.alpla\.net$/,
|
||||
"http://localhost:4173",
|
||||
"http://localhost:4200",
|
||||
"http://localhost:3000",
|
||||
"http://localhost:4000",
|
||||
env.BETTER_AUTH_URL, // prod
|
||||
];
|
||||
|
||||
@@ -124,7 +145,12 @@ const main = async () => {
|
||||
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
||||
credentials: true,
|
||||
exposedHeaders: ["set-cookie"],
|
||||
allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With"],
|
||||
allowedHeaders: [
|
||||
"Content-Type",
|
||||
"Authorization",
|
||||
"X-Requested-With",
|
||||
"XMLHttpRequest",
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user