@bardioc/app-sdk 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-proxy.js +23 -16
- package/dist/vite.js +3 -1
- package/package.json +1 -1
package/dist/dev-proxy.js
CHANGED
|
@@ -49,9 +49,29 @@ export function createDevAuthProxyHandler(options) {
|
|
|
49
49
|
const upstreamPath = url.pathname.slice('/rest'.length) + url.search;
|
|
50
50
|
const upstreamUrl = `${apiBaseUrl}${upstreamPath}`;
|
|
51
51
|
const headers = new Headers();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
// Forward headers from the browser so the BFF sees the same request the host would relay
|
|
53
|
+
// (cookies, origin, referer, etc.). Skip hop-by-hop headers; fetch sets Host from the URL.
|
|
54
|
+
const skipHeaders = new Set([
|
|
55
|
+
'connection',
|
|
56
|
+
'content-length',
|
|
57
|
+
'host',
|
|
58
|
+
'keep-alive',
|
|
59
|
+
'te',
|
|
60
|
+
'transfer-encoding',
|
|
61
|
+
'upgrade',
|
|
62
|
+
]);
|
|
63
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
64
|
+
if (value == null || skipHeaders.has(name.toLowerCase())) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
for (const v of value) {
|
|
69
|
+
headers.append(name, v);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
headers.set(name, value);
|
|
74
|
+
}
|
|
55
75
|
}
|
|
56
76
|
addDevSecretHeader(req, headers, devSecret);
|
|
57
77
|
// The host stamps X-App-ID from its own registration data, never from the app — the
|
|
@@ -61,19 +81,6 @@ export function createDevAuthProxyHandler(options) {
|
|
|
61
81
|
}
|
|
62
82
|
// BFF rejects /bardioc/ calls without this CSRF marker header; stamp it like the host does.
|
|
63
83
|
headers.set('X-Requested-With', 'XMLHttpRequest');
|
|
64
|
-
// Forward a few useful headers from the browser.
|
|
65
|
-
const forwardedHeaders = ['accept', 'accept-language', 'x-scope-id'];
|
|
66
|
-
for (const name of forwardedHeaders) {
|
|
67
|
-
const value = req.headers[name];
|
|
68
|
-
if (typeof value === 'string') {
|
|
69
|
-
headers.set(name, value);
|
|
70
|
-
}
|
|
71
|
-
else if (Array.isArray(value)) {
|
|
72
|
-
for (const v of value) {
|
|
73
|
-
headers.append(name, v);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
84
|
let body;
|
|
78
85
|
try {
|
|
79
86
|
body = await readRequestBody(req);
|
package/dist/vite.js
CHANGED
|
@@ -316,7 +316,9 @@ export function bardiocApp(opts) {
|
|
|
316
316
|
config(_config, env) {
|
|
317
317
|
const isDev = env.command === 'serve';
|
|
318
318
|
return {
|
|
319
|
-
|
|
319
|
+
// Dev runs standalone without the host, so a root base avoids a
|
|
320
|
+
// base path in the Referer/Origin that the BFF may reject.
|
|
321
|
+
base: isDev ? '/' : './',
|
|
320
322
|
server: {
|
|
321
323
|
port,
|
|
322
324
|
allowedHosts: true,
|