Fix local network authentication
This commit is contained in:
@@ -72,8 +72,10 @@ export default defineConfig(({ mode }) => {
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
cookieDomainRewrite: {
|
||||
"dashboard.kent.pw": "localhost",
|
||||
"dashboard.kent.pw": "",
|
||||
},
|
||||
hostRewrite: true,
|
||||
autoRewrite: true,
|
||||
configure: (proxy, _options) => {
|
||||
proxy.on("error", (err, req, res) => {
|
||||
console.log("Auth proxy error:", err);
|
||||
@@ -85,13 +87,29 @@ export default defineConfig(({ mode }) => {
|
||||
);
|
||||
});
|
||||
proxy.on("proxyReq", (proxyReq, req, _res) => {
|
||||
proxyReq.setHeader('X-Forwarded-Host', req.headers.host);
|
||||
proxyReq.setHeader('X-Forwarded-Proto', 'http');
|
||||
|
||||
const origin = req.headers.origin || `http://${req.headers.host}`;
|
||||
proxyReq.setHeader('origin', origin);
|
||||
|
||||
console.log("Outgoing auth request:", {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
headers: req.headers,
|
||||
headers: proxyReq.getHeaders(),
|
||||
});
|
||||
});
|
||||
proxy.on("proxyRes", (proxyRes, req, _res) => {
|
||||
proxy.on("proxyRes", (proxyRes, req, res) => {
|
||||
const cookies = proxyRes.headers['set-cookie'];
|
||||
if (cookies) {
|
||||
proxyRes.headers['set-cookie'] = cookies.map(cookie =>
|
||||
cookie
|
||||
.replace(/Domain=[^;]+;/g, '')
|
||||
.replace(/Secure;/g, '')
|
||||
.replace(/SameSite=None/g, 'SameSite=Lax')
|
||||
);
|
||||
}
|
||||
|
||||
console.log("Auth proxy response:", {
|
||||
statusCode: proxyRes.statusCode,
|
||||
url: req.url,
|
||||
|
||||
Reference in New Issue
Block a user