dinou 4.0.2 ā 4.0.3
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/CHANGELOG.md +6 -0
- package/dinou/core/server.js +46 -28
- package/dinou/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [4.0.3]
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Add missing headers (e.g. authorization) to headers whitelist.
|
|
13
|
+
|
|
8
14
|
## [4.0.2]
|
|
9
15
|
|
|
10
16
|
### Fixed
|
package/dinou/core/server.js
CHANGED
|
@@ -54,11 +54,11 @@ if (isDevelopment) {
|
|
|
54
54
|
process.cwd(),
|
|
55
55
|
isWebpack
|
|
56
56
|
? `${outputFolder}/react-client-manifest.json`
|
|
57
|
-
: `react_client_manifest/react-client-manifest.json
|
|
57
|
+
: `react_client_manifest/react-client-manifest.json`,
|
|
58
58
|
);
|
|
59
59
|
const manifestFolderPath = path.resolve(
|
|
60
60
|
process.cwd(),
|
|
61
|
-
isWebpack ? outputFolder : "react_client_manifest"
|
|
61
|
+
isWebpack ? outputFolder : "react_client_manifest",
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
let manifestWatcher = null;
|
|
@@ -139,7 +139,7 @@ if (isDevelopment) {
|
|
|
139
139
|
}
|
|
140
140
|
} catch (err) {
|
|
141
141
|
console.warn(
|
|
142
|
-
`[Server HMR] Could not resolve or clear ${modulePath}: ${err.message}
|
|
142
|
+
`[Server HMR] Could not resolve or clear ${modulePath}: ${err.message}`,
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -234,7 +234,7 @@ if (!isDevelopment) {
|
|
|
234
234
|
process.cwd(),
|
|
235
235
|
isWebpack
|
|
236
236
|
? `${outputFolder}/server-functions-manifest.json`
|
|
237
|
-
: `server_functions_manifest/server-functions-manifest.json
|
|
237
|
+
: `server_functions_manifest/server-functions-manifest.json`,
|
|
238
238
|
); // Adjust 'dist/' to your outdir
|
|
239
239
|
if (existsSync(manifestPath)) {
|
|
240
240
|
serverFunctionsManifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
@@ -258,7 +258,7 @@ function getContext(req, res) {
|
|
|
258
258
|
const safeResCall = (methodName, ...args) => {
|
|
259
259
|
if (res.headersSent) {
|
|
260
260
|
console.log(
|
|
261
|
-
`[Dinou] res.${methodName} called but headers already sent. Ignoring
|
|
261
|
+
`[Dinou] res.${methodName} called but headers already sent. Ignoring.`,
|
|
262
262
|
);
|
|
263
263
|
// console.warn(
|
|
264
264
|
// `[Dinou Warning] RSC Stream active. Ignoring res.${methodName}() to avoid crash.`
|
|
@@ -301,6 +301,12 @@ function getContext(req, res) {
|
|
|
301
301
|
cookie: req.headers["cookie"],
|
|
302
302
|
referer: req.headers["referer"],
|
|
303
303
|
host: req.headers["host"],
|
|
304
|
+
authorization: req.headers["authorization"],
|
|
305
|
+
"accept-language": req.headers["accept-language"],
|
|
306
|
+
"x-forwarded-for": req.headers["x-forwarded-for"],
|
|
307
|
+
forwarded: req.headers["forwarded"],
|
|
308
|
+
"content-type": req.headers["content-type"],
|
|
309
|
+
origin: req.headers["origin"],
|
|
304
310
|
},
|
|
305
311
|
query: { ...req.query },
|
|
306
312
|
path: req.path,
|
|
@@ -344,6 +350,12 @@ function getContextForServerFunctionEndpoint(req, res) {
|
|
|
344
350
|
cookie: req.headers["cookie"],
|
|
345
351
|
referer: req.headers["referer"],
|
|
346
352
|
host: req.headers["host"],
|
|
353
|
+
authorization: req.headers["authorization"],
|
|
354
|
+
"accept-language": req.headers["accept-language"],
|
|
355
|
+
"x-forwarded-for": req.headers["x-forwarded-for"],
|
|
356
|
+
forwarded: req.headers["forwarded"],
|
|
357
|
+
"content-type": req.headers["content-type"],
|
|
358
|
+
origin: req.headers["origin"],
|
|
347
359
|
},
|
|
348
360
|
query: { ...req.query },
|
|
349
361
|
path: req.path,
|
|
@@ -385,7 +397,7 @@ function getContextForServerFunctionEndpoint(req, res) {
|
|
|
385
397
|
// š Security: JS cannot write HttpOnly cookies
|
|
386
398
|
if (options && options.httpOnly) {
|
|
387
399
|
console.error(
|
|
388
|
-
`[Dinou Error] Cannot set HttpOnly cookie '${name}' in Server Function endpoint because streaming has started
|
|
400
|
+
`[Dinou Error] Cannot set HttpOnly cookie '${name}' in Server Function endpoint because streaming has started.`,
|
|
389
401
|
);
|
|
390
402
|
return;
|
|
391
403
|
}
|
|
@@ -426,7 +438,7 @@ function getContextForServerFunctionEndpoint(req, res) {
|
|
|
426
438
|
const safePath = JSON.stringify(path);
|
|
427
439
|
|
|
428
440
|
res.write(
|
|
429
|
-
`<script>document.cookie = ${safeName} + "=; Max-Age=0; path=" + ${safePath} + ";";</script
|
|
441
|
+
`<script>document.cookie = ${safeName} + "=; Max-Age=0; path=" + ${safePath} + ";";</script>`,
|
|
430
442
|
);
|
|
431
443
|
},
|
|
432
444
|
},
|
|
@@ -465,10 +477,10 @@ if (!isDevelopment) {
|
|
|
465
477
|
process.cwd(),
|
|
466
478
|
isWebpack
|
|
467
479
|
? `${outputFolder}/react-client-manifest.json`
|
|
468
|
-
: `react_client_manifest/react-client-manifest.json
|
|
480
|
+
: `react_client_manifest/react-client-manifest.json`,
|
|
469
481
|
),
|
|
470
|
-
"utf8"
|
|
471
|
-
)
|
|
482
|
+
"utf8",
|
|
483
|
+
),
|
|
472
484
|
);
|
|
473
485
|
}
|
|
474
486
|
|
|
@@ -484,9 +496,9 @@ async function serveRSCPayload(req, res, isOld = false, isStatic = false) {
|
|
|
484
496
|
? "/____rsc_payload_old_static____"
|
|
485
497
|
: "/____rsc_payload_old____"
|
|
486
498
|
: isStatic
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
""
|
|
499
|
+
? "/____rsc_payload_static____"
|
|
500
|
+
: "/____rsc_payload____",
|
|
501
|
+
"",
|
|
490
502
|
);
|
|
491
503
|
// 1. Correct Map initialization
|
|
492
504
|
if (!isDynamic.has(reqPath)) {
|
|
@@ -512,7 +524,7 @@ async function serveRSCPayload(req, res, isOld = false, isStatic = false) {
|
|
|
512
524
|
const payloadPath = path.resolve(
|
|
513
525
|
"dist2",
|
|
514
526
|
reqPath.replace(/^\//, ""),
|
|
515
|
-
isOld || regenerating.has(reqPath) ? "rsc._old.rsc" : "rsc.rsc"
|
|
527
|
+
isOld || regenerating.has(reqPath) ? "rsc._old.rsc" : "rsc.rsc",
|
|
516
528
|
);
|
|
517
529
|
const distDir = path.resolve("dist2");
|
|
518
530
|
|
|
@@ -546,7 +558,7 @@ async function serveRSCPayload(req, res, isOld = false, isStatic = false) {
|
|
|
546
558
|
reqPath,
|
|
547
559
|
{ ...req.query },
|
|
548
560
|
isNotFound,
|
|
549
|
-
isDevelopment
|
|
561
|
+
isDevelopment,
|
|
550
562
|
);
|
|
551
563
|
const manifest = isDevelopment
|
|
552
564
|
? JSON.parse(
|
|
@@ -555,10 +567,10 @@ async function serveRSCPayload(req, res, isOld = false, isStatic = false) {
|
|
|
555
567
|
process.cwd(),
|
|
556
568
|
isWebpack
|
|
557
569
|
? `${outputFolder}/react-client-manifest.json`
|
|
558
|
-
: `react_client_manifest/react-client-manifest.json
|
|
570
|
+
: `react_client_manifest/react-client-manifest.json`,
|
|
559
571
|
),
|
|
560
|
-
"utf8"
|
|
561
|
-
)
|
|
572
|
+
"utf8",
|
|
573
|
+
),
|
|
562
574
|
)
|
|
563
575
|
: cachedClientManifest;
|
|
564
576
|
|
|
@@ -596,7 +608,7 @@ app.post(/^\/____rsc_payload_error____\/.*\/?$/, async (req, res) => {
|
|
|
596
608
|
reqPath,
|
|
597
609
|
{ ...req.query },
|
|
598
610
|
req.body.error,
|
|
599
|
-
isDevelopment
|
|
611
|
+
isDevelopment,
|
|
600
612
|
);
|
|
601
613
|
const manifest = isDevelopment
|
|
602
614
|
? JSON.parse(
|
|
@@ -605,10 +617,10 @@ app.post(/^\/____rsc_payload_error____\/.*\/?$/, async (req, res) => {
|
|
|
605
617
|
process.cwd(),
|
|
606
618
|
isWebpack
|
|
607
619
|
? `${outputFolder}/react-client-manifest.json`
|
|
608
|
-
: `react_client_manifest/react-client-manifest.json
|
|
620
|
+
: `react_client_manifest/react-client-manifest.json`,
|
|
609
621
|
),
|
|
610
|
-
"utf8"
|
|
611
|
-
)
|
|
622
|
+
"utf8",
|
|
623
|
+
),
|
|
612
624
|
)
|
|
613
625
|
: cachedClientManifest;
|
|
614
626
|
const { pipe } = renderToPipeableStream(jsx, manifest);
|
|
@@ -702,6 +714,12 @@ app.get(/^\/.*\/?$/, (req, res) => {
|
|
|
702
714
|
cookie: req.headers["cookie"],
|
|
703
715
|
referer: req.headers["referer"],
|
|
704
716
|
host: req.headers["host"],
|
|
717
|
+
authorization: req.headers["authorization"],
|
|
718
|
+
"accept-language": req.headers["accept-language"],
|
|
719
|
+
"x-forwarded-for": req.headers["x-forwarded-for"],
|
|
720
|
+
forwarded: req.headers["forwarded"],
|
|
721
|
+
"content-type": req.headers["content-type"],
|
|
722
|
+
origin: req.headers["origin"],
|
|
705
723
|
},
|
|
706
724
|
path: req.path,
|
|
707
725
|
method: req.method,
|
|
@@ -718,7 +736,7 @@ app.get(/^\/.*\/?$/, (req, res) => {
|
|
|
718
736
|
contextForChild,
|
|
719
737
|
res,
|
|
720
738
|
capturedStatus,
|
|
721
|
-
isDynamic
|
|
739
|
+
isDynamic,
|
|
722
740
|
);
|
|
723
741
|
|
|
724
742
|
res.setHeader("Content-Type", "text/html");
|
|
@@ -805,7 +823,7 @@ app.post("/____server_function____", async (req, res) => {
|
|
|
805
823
|
// 2. Origin Check (NEW)
|
|
806
824
|
if (!isDevelopment && !isOriginAllowed(req)) {
|
|
807
825
|
console.error(
|
|
808
|
-
`[Security] Blocked request from origin: ${req.headers.origin}
|
|
826
|
+
`[Security] Blocked request from origin: ${req.headers.origin}`,
|
|
809
827
|
);
|
|
810
828
|
return res.status(403).json({ error: "Origin not allowed" });
|
|
811
829
|
}
|
|
@@ -932,7 +950,7 @@ app.post("/____server_function____", async (req, res) => {
|
|
|
932
950
|
process.cwd(),
|
|
933
951
|
isWebpack
|
|
934
952
|
? `${outputFolder}/react-client-manifest.json`
|
|
935
|
-
: `react_client_manifest/react-client-manifest.json
|
|
953
|
+
: `react_client_manifest/react-client-manifest.json`,
|
|
936
954
|
);
|
|
937
955
|
// Verify that the manifest exists to avoid errors
|
|
938
956
|
if (!existsSync(manifestPath)) {
|
|
@@ -976,10 +994,10 @@ const http = require("http");
|
|
|
976
994
|
await new Promise((resolve) => {
|
|
977
995
|
server.listen(port, () => {
|
|
978
996
|
console.log(
|
|
979
|
-
`\nš Dinou Server is ready and listening on http://localhost:${port}
|
|
997
|
+
`\nš Dinou Server is ready and listening on http://localhost:${port}`,
|
|
980
998
|
);
|
|
981
999
|
console.log(
|
|
982
|
-
` Environment: ${isDevelopment ? "Development" : "Production"}
|
|
1000
|
+
` Environment: ${isDevelopment ? "Development" : "Production"}`,
|
|
983
1001
|
);
|
|
984
1002
|
resolve();
|
|
985
1003
|
});
|
|
@@ -996,7 +1014,7 @@ const http = require("http");
|
|
|
996
1014
|
.catch((err) => {
|
|
997
1015
|
console.error(
|
|
998
1016
|
"ā [Background] Static generation failed (App continues in Dynamic Mode):",
|
|
999
|
-
err
|
|
1017
|
+
err,
|
|
1000
1018
|
);
|
|
1001
1019
|
isReady = true;
|
|
1002
1020
|
});
|
package/dinou/package.json
CHANGED