maxserver 0.2.3 → 0.2.5
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/package.json +1 -1
- package/src/setup.js +16 -5
- package/src/setupDocs.js +7 -0
package/package.json
CHANGED
package/src/setup.js
CHANGED
|
@@ -21,16 +21,27 @@ export async function setupHelmet(app) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
export async function setupCors(app) {
|
|
25
26
|
const isProd = app.maxserver.env === "production";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
let origin = app.maxserver.cors ?? "*";
|
|
28
|
+
|
|
29
|
+
// Fix: Credentials + "*" = Browser Error
|
|
30
|
+
// If no origin is defined in dev, we should allow the specific requester
|
|
31
|
+
if (origin === "*" && !isProd)
|
|
32
|
+
origin = true; // Fastify-cors treats 'true' as "reflect the request origin"
|
|
33
|
+
|
|
34
|
+
if (isProd && (origin === "*" || origin === true))
|
|
35
|
+
app.log.warn("CORS: allowing all origins in production with credentials is risky");
|
|
36
|
+
|
|
37
|
+
await app.register(cors, {
|
|
38
|
+
origin,
|
|
39
|
+
credentials: true
|
|
40
|
+
});
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
|
|
44
|
+
|
|
34
45
|
export async function setupCookie(app) {
|
|
35
46
|
await app.register(cookie, {
|
|
36
47
|
secret: app.maxserver.secret,
|
package/src/setupDocs.js
CHANGED
|
@@ -85,6 +85,13 @@ export async function setupDocs(app) {
|
|
|
85
85
|
preferredSecurityScheme: 'bearerAuth',
|
|
86
86
|
apiKey: { token: "" }
|
|
87
87
|
},
|
|
88
|
+
customCss: `
|
|
89
|
+
.darklight-reference a[href*="scalar.com"] {
|
|
90
|
+
display: none !important;
|
|
91
|
+
},
|
|
92
|
+
.text-sidebar-c-2 {
|
|
93
|
+
display: none !important;
|
|
94
|
+
}`,
|
|
88
95
|
...app.maxserver.scalar
|
|
89
96
|
}
|
|
90
97
|
});
|