vike 0.4.193-commit-c1d490a → 0.4.194
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/cjs/node/plugin/plugins/importUserCode/index.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -13
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/cjs/node/plugin/shared/loggerVite.js +0 -3
- package/dist/cjs/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +16 -9
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +4 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -12
- package/dist/cjs/node/runtime/renderPage.js +59 -64
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/parseUrl-extras.js +6 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd/log.d.ts +0 -7
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +0 -12
- package/dist/esm/node/plugin/shared/loggerNotProd.d.ts +1 -7
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -24
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -4
- package/dist/esm/node/runtime/renderPage/assertArguments.js +3 -3
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.d.ts → createHttpResponse.d.ts} +9 -5
- package/dist/esm/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js} +15 -8
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +3 -5
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +4 -3
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +6 -2
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +6 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -11
- package/dist/esm/node/runtime/renderPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage.js +59 -64
- package/dist/esm/shared/route/abort.d.ts +3 -3
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/parseUrl-extras.d.ts +2 -0
- package/dist/esm/utils/parseUrl-extras.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -99,17 +99,13 @@ function handleHotUpdate(ctx, config) {
|
|
|
99
99
|
`${msg} — ${pc.cyan('no HMR')}, see https://vike.dev/on-demand-compiler`,
|
|
100
100
|
'info',
|
|
101
101
|
null,
|
|
102
|
-
true
|
|
103
|
-
clear,
|
|
104
|
-
config
|
|
102
|
+
true
|
|
105
103
|
)
|
|
106
104
|
return
|
|
107
105
|
}
|
|
108
106
|
//*/
|
|
109
|
-
// HMR can resolve errors => we clear previously shown errors.
|
|
110
107
|
// It can hide an error it shouldn't hide (because the error isn't shown again), but it's ok since users can reload the page and the error will be shown again (Vite transpilation errors are shown again upon a page reload).
|
|
111
108
|
if (!isVikeConfig && isViteModule) {
|
|
112
|
-
(0, loggerNotProd_js_1.clearLogs)({ clearErrors: true });
|
|
113
109
|
return;
|
|
114
110
|
}
|
|
115
111
|
if (isVikeConfig) {
|
|
@@ -37,7 +37,7 @@ function reloadVikeConfig(userRootDir, outDirRoot) {
|
|
|
37
37
|
}
|
|
38
38
|
exports.reloadVikeConfig = reloadVikeConfig;
|
|
39
39
|
async function handleReloadSideEffects() {
|
|
40
|
-
wasConfigInvalid = isConfigInvalid_js_1.isConfigInvalid;
|
|
40
|
+
wasConfigInvalid = !!isConfigInvalid_js_1.isConfigInvalid;
|
|
41
41
|
const vikeConfigPromisePrevious = vikeConfigPromise;
|
|
42
42
|
try {
|
|
43
43
|
await vikeConfigPromise;
|
|
@@ -214,7 +214,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
|
|
|
214
214
|
else {
|
|
215
215
|
(0, utils_js_1.assert)(ret === undefined);
|
|
216
216
|
(0, utils_js_1.assert)(err);
|
|
217
|
-
(0, isConfigInvalid_js_1.isConfigInvalid_set)(
|
|
217
|
+
(0, isConfigInvalid_js_1.isConfigInvalid_set)({ err });
|
|
218
218
|
if (!isDev) {
|
|
219
219
|
(0, utils_js_1.assert)((0, globalContext_js_1.getViteDevServer)() === null);
|
|
220
220
|
throw err;
|
|
@@ -48,15 +48,10 @@ function addSsrMiddleware(middlewares, config, isPreview) {
|
|
|
48
48
|
if (value)
|
|
49
49
|
res.setHeader(name, value);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const { statusCode, headers } = pageContext.httpResponse;
|
|
56
|
-
headers.forEach(([name, value]) => res.setHeader(name, value));
|
|
57
|
-
res.statusCode = statusCode;
|
|
58
|
-
pageContext.httpResponse.pipe(res);
|
|
59
|
-
}
|
|
51
|
+
const { httpResponse } = pageContext;
|
|
52
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value));
|
|
53
|
+
res.statusCode = httpResponse.statusCode;
|
|
54
|
+
httpResponse.pipe(res);
|
|
60
55
|
});
|
|
61
56
|
}
|
|
62
57
|
exports.addSsrMiddleware = addSsrMiddleware;
|
|
@@ -3,16 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.applyViteSourceMapToStackTrace = exports.
|
|
6
|
+
exports.applyViteSourceMapToStackTrace = exports.logDirectly = exports.logWithVikeTag = exports.logWithViteTag = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
const isErrorDebug_js_1 = require("../../../shared/isErrorDebug.js");
|
|
10
10
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
11
11
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
12
|
-
let isFirstLog = true;
|
|
13
|
-
exports.isFirstLog = isFirstLog;
|
|
14
|
-
let screenHasErrors = false;
|
|
15
|
-
exports.screenHasErrors = screenHasErrors;
|
|
16
12
|
function logWithVikeTag(msg, logType, category, showVikeVersion = false) {
|
|
17
13
|
const projectTag = getProjectTag(showVikeVersion);
|
|
18
14
|
msg = prependTags(msg, projectTag, category, logType);
|
|
@@ -39,7 +35,6 @@ exports.logWithViteTag = logWithViteTag;
|
|
|
39
35
|
// - Production => logs aren't managed by loggerNotProd.ts => logDirectly() is never called (not even loaded as asserted by assertIsVitePluginCode())
|
|
40
36
|
function logDirectly(thing, logType) {
|
|
41
37
|
applyViteSourceMapToStackTrace(thing);
|
|
42
|
-
exports.isFirstLog = isFirstLog = false;
|
|
43
38
|
if (logType === 'info') {
|
|
44
39
|
console.log(thing);
|
|
45
40
|
return;
|
|
@@ -49,7 +44,6 @@ function logDirectly(thing, logType) {
|
|
|
49
44
|
return;
|
|
50
45
|
}
|
|
51
46
|
if (logType === 'error') {
|
|
52
|
-
exports.screenHasErrors = screenHasErrors = true;
|
|
53
47
|
console.error(thing);
|
|
54
48
|
return;
|
|
55
49
|
}
|
|
@@ -61,12 +55,6 @@ function logDirectly(thing, logType) {
|
|
|
61
55
|
(0, utils_js_1.assert)(false);
|
|
62
56
|
}
|
|
63
57
|
exports.logDirectly = logDirectly;
|
|
64
|
-
function clearScreen(viteConfig) {
|
|
65
|
-
// We use Vite's logger in order to respect the user's `clearScreen: false` setting
|
|
66
|
-
viteConfig.logger.clearScreen('error');
|
|
67
|
-
exports.screenHasErrors = screenHasErrors = false;
|
|
68
|
-
}
|
|
69
|
-
exports.clearScreen = clearScreen;
|
|
70
58
|
function applyViteSourceMapToStackTrace(thing) {
|
|
71
59
|
if ((0, isErrorDebug_js_1.isErrorDebug)())
|
|
72
60
|
return;
|
|
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.logErrorDebugNote = exports.logConfigErrorRecover = exports.logConfigError = exports.logConfigInfo = exports.logViteError = exports.logViteAny = void 0;
|
|
13
13
|
const abort_js_1 = require("../../../shared/route/abort.js");
|
|
14
14
|
const globalContext_js_1 = require("../../runtime/globalContext.js");
|
|
15
15
|
const loggerRuntime_js_1 = require("../../runtime/renderPage/loggerRuntime.js");
|
|
@@ -21,15 +21,12 @@ const transpileAndExecuteFile_js_1 = require("../plugins/importUserCode/v1-desig
|
|
|
21
21
|
const log_js_1 = require("./loggerNotProd/log.js");
|
|
22
22
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
23
23
|
const isNewError_js_1 = require("../../runtime/renderPage/isNewError.js");
|
|
24
|
-
const isConfigInvalid_js_1 = require("../../runtime/renderPage/isConfigInvalid.js");
|
|
25
24
|
const loggerProd_js_1 = require("../../runtime/renderPage/loggerProd.js");
|
|
26
25
|
const executeHook_js_1 = require("../../../shared/hooks/executeHook.js");
|
|
27
26
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
28
27
|
(0, loggerRuntime_js_1.overwriteRuntimeProductionLogger)(logRuntimeError, logRuntimeInfo);
|
|
29
28
|
(0, utils_js_1.overwriteAssertProductionLogger)(assertLogger);
|
|
30
|
-
function logRuntimeInfo(msg, httpRequestId, logType
|
|
31
|
-
if (clearErrors)
|
|
32
|
-
clearLogs({ clearErrors: true });
|
|
29
|
+
function logRuntimeInfo(msg, httpRequestId, logType) {
|
|
33
30
|
const category = getCategory(httpRequestId);
|
|
34
31
|
(0, utils_js_1.assert)(category);
|
|
35
32
|
(0, log_js_1.logWithVikeTag)(msg, logType, category);
|
|
@@ -51,7 +48,6 @@ function logConfigInfo(msg, logType) {
|
|
|
51
48
|
exports.logConfigInfo = logConfigInfo;
|
|
52
49
|
function logConfigErrorRecover() {
|
|
53
50
|
const msg = picocolors_1.default.bold(picocolors_1.default.green('Configuration successfully loaded'));
|
|
54
|
-
clearLogs({ clearAlsoIfConfigIsInvalid: true });
|
|
55
51
|
const category = getConfigCategory();
|
|
56
52
|
(0, log_js_1.logWithVikeTag)(msg, 'error-recover', category);
|
|
57
53
|
}
|
|
@@ -113,7 +109,6 @@ function logErr(err, httpRequestId = null, errorComesFromVite) {
|
|
|
113
109
|
(0, loggerProd_js_1.onRuntimeError)(err);
|
|
114
110
|
}
|
|
115
111
|
function logConfigError(err) {
|
|
116
|
-
clearLogs({ clearAlsoIfConfigIsInvalid: true });
|
|
117
112
|
(0, utils_js_1.warnIfErrorIsNotObject)(err);
|
|
118
113
|
const category = getConfigCategory();
|
|
119
114
|
{
|
|
@@ -177,23 +172,6 @@ function assertLogger(thing, logType) {
|
|
|
177
172
|
const { assertMsg, showVikeVersion } = res;
|
|
178
173
|
(0, log_js_1.logWithVikeTag)(assertMsg, logType, category, showVikeVersion);
|
|
179
174
|
}
|
|
180
|
-
function clearLogs(conditions = {}) {
|
|
181
|
-
if (!conditions.clearAlsoIfConfigIsInvalid && isConfigInvalid_js_1.isConfigInvalid) {
|
|
182
|
-
// Avoid hiding the config error: the config error is printed only once
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (conditions.clearErrors && !log_js_1.screenHasErrors) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (conditions.clearIfFirstLog && !log_js_1.isFirstLog) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const viteConfig = (0, globalContext_js_1.getViteConfig)();
|
|
192
|
-
if (viteConfig) {
|
|
193
|
-
(0, log_js_1.clearScreen)(viteConfig);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.clearLogs = clearLogs;
|
|
197
175
|
/** Note shown to user when vike does something risky:
|
|
198
176
|
* - When vike dedupes (i.e. swallows) an error with getHttpRequestAsyncStore().shouldErrorBeSwallowed(err)
|
|
199
177
|
* - When vike modifies the error with getPrettyErrorWithCodeSnippet(err)
|
|
@@ -39,9 +39,6 @@ function intercept(logType, config) {
|
|
|
39
39
|
(0, utils_js_1.assert)(!(0, isErrorDebug_js_1.isErrorDebug)());
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
// Only allow Vite to clear for its first log. All other clearing is controlled by vike.
|
|
43
|
-
if (options.clear)
|
|
44
|
-
(0, loggerNotProd_js_1.clearLogs)({ clearIfFirstLog: true });
|
|
45
42
|
// Vite's default logger preprends the "[vite]" tag if and only if options.timestamp is true
|
|
46
43
|
const prependViteTag = options.timestamp || !!store?.httpRequestId;
|
|
47
44
|
(0, loggerNotProd_js_1.logViteAny)(msg, logType, store?.httpRequestId ?? null, prependViteTag);
|
|
@@ -7,14 +7,14 @@ exports.assertArguments = void 0;
|
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
9
|
function assertArguments(...args) {
|
|
10
|
-
const prefix =
|
|
10
|
+
const prefix = `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage)`;
|
|
11
11
|
const pageContextInit = args[0];
|
|
12
12
|
(0, utils_js_1.assertUsage)(pageContextInit !== undefined && pageContextInit !== null, prefix + ` argument ${picocolors_1.default.cyan('pageContextInit')} is missing`, { showStackTrace: true });
|
|
13
13
|
const len = args.length;
|
|
14
|
-
(0, utils_js_1.assertUsage)(len === 1, `${prefix}
|
|
14
|
+
(0, utils_js_1.assertUsage)(len === 1, `${prefix} called with ${len} arguments but renderPage() accepts only one argument.'`, {
|
|
15
15
|
showStackTrace: true
|
|
16
16
|
});
|
|
17
|
-
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(pageContextInit), `${prefix}
|
|
17
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(pageContextInit), `${prefix} called with ${picocolors_1.default.code(`typeof pageContextInit === ${JSON.stringify(typeof pageContextInit)}`)} but ${picocolors_1.default.code('pageContextInit')} should be an object.`, { showStackTrace: true });
|
|
18
18
|
// TODO/v1-release: remove
|
|
19
19
|
if ('url' in pageContextInit) {
|
|
20
20
|
(0, utils_js_1.assertWarning)(false, '`pageContextInit.url` has been renamed to `pageContextInit.urlOriginal`: replace `renderPage({ url })` with `renderPage({ urlOriginal })`. (See https://vike.dev/migration/0.4.23 for more information.)', { showStackTrace: true, onlyOnce: true });
|
package/dist/cjs/node/runtime/renderPage/{createHttpResponseObject.js → createHttpResponse.js}
RENAMED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createHttpResponseFavicon404 = exports.createHttpResponseRedirect = exports.createHttpResponseError = exports.createHttpResponsePageContextJson = exports.createHttpResponse = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
const error_page_js_1 = require("../../../shared/error-page.js");
|
|
6
6
|
const getHttpResponseBody_js_1 = require("./getHttpResponseBody.js");
|
|
7
7
|
const getEarlyHints_js_1 = require("./getEarlyHints.js");
|
|
8
8
|
const getCacheControl_js_1 = require("./createHttpResponseObject/getCacheControl.js");
|
|
9
9
|
const assertNoInfiniteHttpRedirect_js_1 = require("./createHttpResponseObject/assertNoInfiniteHttpRedirect.js");
|
|
10
|
-
async function
|
|
11
|
-
if (htmlRender === null) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
10
|
+
async function createHttpResponse(htmlRender, renderHook, pageContext) {
|
|
14
11
|
let statusCode = pageContext.abortStatusCode;
|
|
15
12
|
if (!statusCode) {
|
|
16
13
|
const isError = !pageContext._pageId || (0, error_page_js_1.isErrorPage)(pageContext._pageId, pageContext._pageConfigs);
|
|
@@ -35,13 +32,23 @@ async function createHttpResponseObject(htmlRender, renderHook, pageContext) {
|
|
|
35
32
|
}
|
|
36
33
|
return getHttpResponse(statusCode, 'text/html;charset=utf-8', headers, htmlRender, earlyHints, renderHook);
|
|
37
34
|
}
|
|
38
|
-
exports.
|
|
35
|
+
exports.createHttpResponse = createHttpResponse;
|
|
36
|
+
function createHttpResponseFavicon404() {
|
|
37
|
+
const httpResponse = getHttpResponse(404, 'text/html;charset=utf-8', [], "<p>No favicon.ico found.</p><script>console.log('This HTTP response was generated by Vike.')</script>");
|
|
38
|
+
return httpResponse;
|
|
39
|
+
}
|
|
40
|
+
exports.createHttpResponseFavicon404 = createHttpResponseFavicon404;
|
|
41
|
+
function createHttpResponseError() {
|
|
42
|
+
const httpResponse = getHttpResponse(500, 'text/html;charset=utf-8', [], "<p>An error occurred.</p><script>console.log('This HTTP response was generated by Vike. This response is used instead of rendering the error page (https://vike.dev/error-page), either because there isn't error page or because an error occurred while rendering the error page.')</script>");
|
|
43
|
+
return httpResponse;
|
|
44
|
+
}
|
|
45
|
+
exports.createHttpResponseError = createHttpResponseError;
|
|
39
46
|
async function createHttpResponsePageContextJson(pageContextSerialized) {
|
|
40
47
|
const httpResponse = getHttpResponse(200, 'application/json', [], pageContextSerialized, [], null);
|
|
41
48
|
return httpResponse;
|
|
42
49
|
}
|
|
43
50
|
exports.createHttpResponsePageContextJson = createHttpResponsePageContextJson;
|
|
44
|
-
function
|
|
51
|
+
function createHttpResponseRedirect({ url, statusCode },
|
|
45
52
|
// The URL we assume the redirect to be logically based on
|
|
46
53
|
urlLogical) {
|
|
47
54
|
(0, assertNoInfiniteHttpRedirect_js_1.assertNoInfiniteHttpRedirect)(url, urlLogical);
|
|
@@ -52,9 +59,9 @@ urlLogical) {
|
|
|
52
59
|
return getHttpResponse(statusCode, 'text/html;charset=utf-8', headers,
|
|
53
60
|
// For bots / programmatic crawlig: show what's going on.
|
|
54
61
|
// For users: showing a blank page is probably better than a flickering text.
|
|
55
|
-
`<p style="display: none">Redirecting to ${url}</p>`);
|
|
62
|
+
`<p style="display: none">Redirecting to ${url}</p><script>console.log('This HTTP response was generated by Vike.')</script>`);
|
|
56
63
|
}
|
|
57
|
-
exports.
|
|
64
|
+
exports.createHttpResponseRedirect = createHttpResponseRedirect;
|
|
58
65
|
function getHttpResponse(statusCode, contentType, headers, htmlRender, earlyHints = [], renderHook = null) {
|
|
59
66
|
headers.push(['Content-Type', contentType]);
|
|
60
67
|
(0, utils_js_1.assert)(renderHook || typeof htmlRender === 'string');
|
|
@@ -22,9 +22,6 @@ async function executeOnRenderHtmlHook(pageContext) {
|
|
|
22
22
|
const { documentHtml, pageContextProvidedByRenderHook, pageContextPromise, injectFilter } = processHookReturnValue(hookReturnValue, renderHook);
|
|
23
23
|
Object.assign(pageContext, pageContextProvidedByRenderHook);
|
|
24
24
|
(0, utils_js_1.objectAssign)(pageContext, { _pageContextPromise: pageContextPromise });
|
|
25
|
-
if (documentHtml === null || documentHtml === undefined) {
|
|
26
|
-
return { htmlRender: null, renderHook };
|
|
27
|
-
}
|
|
28
25
|
const onErrorWhileStreaming = (err) => {
|
|
29
26
|
// Should the stream inject the following?
|
|
30
27
|
// ```
|
|
@@ -81,7 +78,7 @@ function getRenderHook(pageContext) {
|
|
|
81
78
|
return hookFound;
|
|
82
79
|
}
|
|
83
80
|
function processHookReturnValue(hookReturnValue, renderHook) {
|
|
84
|
-
let documentHtml
|
|
81
|
+
let documentHtml;
|
|
85
82
|
let pageContextPromise = null;
|
|
86
83
|
let pageContextProvidedByRenderHook = null;
|
|
87
84
|
let injectFilter = null;
|
|
@@ -108,7 +105,8 @@ function processHookReturnValue(hookReturnValue, renderHook) {
|
|
|
108
105
|
(0, utils_js_1.assertUsage)((0, utils_js_1.isCallable)(hookReturnValue.injectFilter), 'injectFilter should be a function');
|
|
109
106
|
injectFilter = hookReturnValue.injectFilter;
|
|
110
107
|
}
|
|
111
|
-
|
|
108
|
+
(0, utils_js_1.assertUsage)(hookReturnValue.documentHtml, `${errPrefix} returned an object that is missing the ${picocolors_1.default.code('documentHtml')} property.`);
|
|
109
|
+
{
|
|
112
110
|
let val = hookReturnValue.documentHtml;
|
|
113
111
|
const errBegin = `${errPrefix} returned ${picocolors_1.default.cyan('{ documentHtml }')}, but ${picocolors_1.default.cyan('documentHtml')}`;
|
|
114
112
|
if (typeof val === 'string') {
|
|
@@ -7,7 +7,7 @@ exports.handleErrorWithoutErrorPage = void 0;
|
|
|
7
7
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
8
8
|
const globalContext_js_1 = require("../globalContext.js");
|
|
9
9
|
const utils_js_1 = require("../utils.js");
|
|
10
|
-
const
|
|
10
|
+
const createHttpResponse_js_1 = require("./createHttpResponse.js");
|
|
11
11
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
12
|
// When the user hasn't defined _error.page.js
|
|
13
13
|
async function handleErrorWithoutErrorPage(pageContext) {
|
|
@@ -18,13 +18,14 @@ async function handleErrorWithoutErrorPage(pageContext) {
|
|
|
18
18
|
warnMissingErrorPage(isV1);
|
|
19
19
|
}
|
|
20
20
|
if (!pageContext.isClientSideNavigation) {
|
|
21
|
-
(0,
|
|
21
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseError)();
|
|
22
|
+
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
22
23
|
return pageContext;
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
const __getPageAssets = async () => [];
|
|
26
27
|
(0, utils_js_1.objectAssign)(pageContext, { __getPageAssets });
|
|
27
|
-
const httpResponse = await (0,
|
|
28
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponse)((0, stringify_1.stringify)({ serverSideError: true }), null, pageContext);
|
|
28
29
|
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
29
30
|
return pageContext;
|
|
30
31
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isConfigInvalid_set = exports.isConfigInvalid = void 0;
|
|
4
|
-
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
let isConfigInvalid;
|
|
5
6
|
const isConfigInvalid_set = (val) => {
|
|
6
|
-
|
|
7
|
+
(0, utils_js_1.assert)(val === false || val.err);
|
|
8
|
+
exports.isConfigInvalid = isConfigInvalid = val;
|
|
7
9
|
};
|
|
8
10
|
exports.isConfigInvalid_set = isConfigInvalid_set;
|
|
@@ -11,7 +11,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
11
11
|
const serializePageContextClientSide_js_1 = require("../html/serializePageContextClientSide.js");
|
|
12
12
|
const getPageContextUrlComputed_js_1 = require("../../../shared/getPageContextUrlComputed.js");
|
|
13
13
|
const globalContext_js_1 = require("../globalContext.js");
|
|
14
|
-
const
|
|
14
|
+
const createHttpResponse_js_1 = require("./createHttpResponse.js");
|
|
15
15
|
const loadUserFilesServerSide_js_1 = require("./loadUserFilesServerSide.js");
|
|
16
16
|
const executeOnRenderHtmlHook_js_1 = require("./executeOnRenderHtmlHook.js");
|
|
17
17
|
const executeOnBeforeRenderAndDataHooks_js_1 = require("./executeOnBeforeRenderAndDataHooks.js");
|
|
@@ -52,21 +52,15 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
52
52
|
(0, utils_js_1.objectAssign)(pageContext, { [isServerSideError_js_1.isServerSideError]: true });
|
|
53
53
|
}
|
|
54
54
|
const pageContextSerialized = (0, serializePageContextClientSide_js_1.serializePageContextClientSide)(pageContext);
|
|
55
|
-
const httpResponse = await (0,
|
|
55
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePageContextJson)(pageContextSerialized);
|
|
56
56
|
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
57
57
|
return pageContext;
|
|
58
58
|
}
|
|
59
59
|
const renderHookResult = await (0, executeOnRenderHtmlHook_js_1.executeOnRenderHtmlHook)(pageContext);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else {
|
|
65
|
-
const { htmlRender, renderHook } = renderHookResult;
|
|
66
|
-
const httpResponse = await (0, createHttpResponseObject_js_1.createHttpResponseObject)(htmlRender, renderHook, pageContext);
|
|
67
|
-
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
68
|
-
return pageContext;
|
|
69
|
-
}
|
|
60
|
+
const { htmlRender, renderHook } = renderHookResult;
|
|
61
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponse)(htmlRender, renderHook, pageContext);
|
|
62
|
+
(0, utils_js_1.objectAssign)(pageContext, { httpResponse });
|
|
63
|
+
return pageContext;
|
|
70
64
|
}
|
|
71
65
|
exports.renderPageAlreadyRouted = renderPageAlreadyRouted;
|
|
72
66
|
async function prerenderPage(pageContext) {
|
|
@@ -10,7 +10,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
10
10
|
const abort_js_1 = require("../../shared/route/abort.js");
|
|
11
11
|
const globalContext_js_1 = require("./globalContext.js");
|
|
12
12
|
const handlePageContextRequestUrl_js_1 = require("./renderPage/handlePageContextRequestUrl.js");
|
|
13
|
-
const
|
|
13
|
+
const createHttpResponse_js_1 = require("./renderPage/createHttpResponse.js");
|
|
14
14
|
const loggerRuntime_js_1 = require("./renderPage/loggerRuntime.js");
|
|
15
15
|
const isNewError_js_1 = require("./renderPage/isNewError.js");
|
|
16
16
|
const assertArguments_js_1 = require("./renderPage/assertArguments.js");
|
|
@@ -23,8 +23,7 @@ const handleErrorWithoutErrorPage_js_1 = require("./renderPage/handleErrorWithou
|
|
|
23
23
|
const loadUserFilesServerSide_js_1 = require("./renderPage/loadUserFilesServerSide.js");
|
|
24
24
|
const resolveRedirects_js_1 = require("./renderPage/resolveRedirects.js");
|
|
25
25
|
const globalObject = (0, utils_js_1.getGlobalObject)('runtime/renderPage.ts', {
|
|
26
|
-
httpRequestsCount: 0
|
|
27
|
-
pendingRequestsCount: 0
|
|
26
|
+
httpRequestsCount: 0
|
|
28
27
|
});
|
|
29
28
|
let renderPage_wrapper = async (_httpRequestId, ret) => ({
|
|
30
29
|
pageContextReturn: await ret()
|
|
@@ -36,33 +35,35 @@ exports.renderPage_addWrapper = renderPage_addWrapper;
|
|
|
36
35
|
// `renderPage()` calls `renderPageNominal()` while ensuring that errors are `console.error(err)` instead of `throw err`, so that Vike never triggers a server shut down. (Throwing an error in an Express.js middleware shuts down the whole Express.js server.)
|
|
37
36
|
async function renderPage(pageContextInit) {
|
|
38
37
|
(0, assertArguments_js_1.assertArguments)(...arguments);
|
|
39
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextInit, 'urlOriginal', 'string'));
|
|
38
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextInit, 'urlOriginal', 'string')); // assertUsage() already implemented at assertArguments()
|
|
40
39
|
(0, utils_js_1.assertEnv)();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
assertIsUrl(pageContextInit.urlOriginal);
|
|
41
|
+
const urlPathnameWithBase = (0, utils_js_1.parseUrl)(pageContextInit.urlOriginal, '/').pathname;
|
|
42
|
+
assertIsNotViteRequest(urlPathnameWithBase, pageContextInit.urlOriginal);
|
|
43
|
+
if (urlPathnameWithBase.endsWith('/favicon.ico'))
|
|
44
|
+
return getPageContextHttpResponseFavicon404(pageContextInit);
|
|
46
45
|
const httpRequestId = getRequestId();
|
|
47
|
-
const
|
|
48
|
-
logHttpRequest(
|
|
49
|
-
globalObject.pendingRequestsCount++;
|
|
46
|
+
const urlOriginalPretty = (0, utils_js_1.getUrlPretty)(pageContextInit.urlOriginal);
|
|
47
|
+
logHttpRequest(urlOriginalPretty, httpRequestId);
|
|
50
48
|
const { pageContextReturn } = await renderPage_wrapper(httpRequestId, () => renderPageAndPrepare(pageContextInit, httpRequestId));
|
|
51
|
-
logHttpResponse(
|
|
52
|
-
globalObject.pendingRequestsCount--;
|
|
49
|
+
logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn);
|
|
53
50
|
(0, utils_js_1.checkType)(pageContextReturn);
|
|
51
|
+
(0, utils_js_1.assert)(pageContextReturn.httpResponse);
|
|
54
52
|
return pageContextReturn;
|
|
55
53
|
}
|
|
56
54
|
exports.renderPage = renderPage;
|
|
57
55
|
async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
58
56
|
// Invalid config
|
|
59
|
-
const handleInvalidConfig = () => {
|
|
57
|
+
const handleInvalidConfig = (err) => {
|
|
60
58
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
|
|
61
|
-
const
|
|
62
|
-
return
|
|
59
|
+
const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit);
|
|
60
|
+
return pageContextWithError;
|
|
63
61
|
};
|
|
64
62
|
if (isConfigInvalid_js_1.isConfigInvalid) {
|
|
65
|
-
|
|
63
|
+
if (1 < 2 // Make TS happy
|
|
64
|
+
) {
|
|
65
|
+
return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
// Prepare context
|
|
68
69
|
let renderContext;
|
|
@@ -75,21 +76,17 @@ async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
|
75
76
|
// initGlobalContext_renderPage() and getRenderContext() don't call any user hooks => err isn't thrown from user code.
|
|
76
77
|
(0, utils_js_1.assert)(!(0, abort_js_1.isAbortError)(err));
|
|
77
78
|
(0, loggerRuntime_js_1.logRuntimeError)(err, httpRequestId);
|
|
78
|
-
const
|
|
79
|
-
return
|
|
79
|
+
const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit);
|
|
80
|
+
return pageContextWithError;
|
|
80
81
|
}
|
|
81
82
|
if (isConfigInvalid_js_1.isConfigInvalid) {
|
|
82
|
-
return handleInvalidConfig();
|
|
83
|
+
return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
|
|
83
84
|
}
|
|
84
85
|
else {
|
|
85
86
|
// From now on, renderContext.pageConfigs contains all the configuration data; getVikeConfig() isn't called anymore for this request
|
|
86
87
|
}
|
|
87
88
|
// Check Base URL
|
|
88
|
-
|
|
89
|
-
const pageContextHttpResponse = checkBaseUrl(pageContextInit, httpRequestId);
|
|
90
|
-
if (pageContextHttpResponse)
|
|
91
|
-
return pageContextHttpResponse;
|
|
92
|
-
}
|
|
89
|
+
assertBaseUrl(pageContextInit);
|
|
93
90
|
// Normalize URL
|
|
94
91
|
{
|
|
95
92
|
const pageContextHttpResponse = normalizeUrl(pageContextInit, httpRequestId);
|
|
@@ -185,8 +182,8 @@ async function renderPageAlreadyPrepared(pageContextInit, httpRequestId, renderC
|
|
|
185
182
|
if (!handled.pageContextReturn) {
|
|
186
183
|
const pageContextAbort = errErrorPage._pageContextAbort;
|
|
187
184
|
(0, utils_js_1.assertWarning)(false, `Failed to render error page because ${picocolors_1.default.cyan(pageContextAbort._abortCall)} was called: make sure ${picocolors_1.default.cyan(pageContextAbort._abortCaller)} doesn't occur while the error page is being rendered.`, { onlyOnce: false });
|
|
188
|
-
const
|
|
189
|
-
return
|
|
185
|
+
const pageContextHttpWithError = getPageContextHttpResponseError(errNominalPage, pageContextInit);
|
|
186
|
+
return pageContextHttpWithError;
|
|
190
187
|
}
|
|
191
188
|
// `throw redirect()` / `throw render(url)`
|
|
192
189
|
return handled.pageContextReturn;
|
|
@@ -194,20 +191,19 @@ async function renderPageAlreadyPrepared(pageContextInit, httpRequestId, renderC
|
|
|
194
191
|
if ((0, isNewError_js_1.isNewError)(errErrorPage, errNominalPage)) {
|
|
195
192
|
(0, loggerRuntime_js_1.logRuntimeError)(errErrorPage, httpRequestId);
|
|
196
193
|
}
|
|
197
|
-
const
|
|
198
|
-
return
|
|
194
|
+
const pageContextWithError = getPageContextHttpResponseError(errNominalPage, pageContextInit);
|
|
195
|
+
return pageContextWithError;
|
|
199
196
|
}
|
|
200
197
|
return pageContextErrorPage;
|
|
201
198
|
}
|
|
202
199
|
}
|
|
203
200
|
function logHttpRequest(urlOriginal, httpRequestId) {
|
|
204
|
-
|
|
205
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info', clearErrors);
|
|
201
|
+
(0, loggerRuntime_js_1.logRuntimeInfo)?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info');
|
|
206
202
|
}
|
|
207
203
|
function getRequestInfoMessage(urlOriginal) {
|
|
208
204
|
return `HTTP request: ${prettyUrl(urlOriginal)}`;
|
|
209
205
|
}
|
|
210
|
-
function logHttpResponse(
|
|
206
|
+
function logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn) {
|
|
211
207
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
212
208
|
let msg;
|
|
213
209
|
let isNominal;
|
|
@@ -218,10 +214,10 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
218
214
|
// - URL doesn't include Base URL
|
|
219
215
|
// - Can we abort earlier so that `logHttpResponse()` and `logHttpRequest()` aren't even called?
|
|
220
216
|
// - Error loading a Vike config file
|
|
221
|
-
// - We should show `HTTP response ${
|
|
217
|
+
// - We should show `HTTP response ${urlOriginalPretty} ERR` instead.
|
|
222
218
|
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
223
219
|
(0, utils_js_1.assert)(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
224
|
-
msg = `HTTP response ${prettyUrl(
|
|
220
|
+
msg = `HTTP response ${prettyUrl(urlOriginalPretty)} ${picocolors_1.default.dim('null')}`;
|
|
225
221
|
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
226
222
|
isNominal = true;
|
|
227
223
|
}
|
|
@@ -239,28 +235,30 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
239
235
|
.find((header) => header[0] === 'Location');
|
|
240
236
|
(0, utils_js_1.assert)(headerRedirect);
|
|
241
237
|
const urlRedirect = headerRedirect[1];
|
|
242
|
-
|
|
238
|
+
urlOriginalPretty = urlRedirect;
|
|
243
239
|
}
|
|
244
|
-
msg = `HTTP ${type} ${prettyUrl(
|
|
240
|
+
msg = `HTTP ${type} ${prettyUrl(urlOriginalPretty)} ${color(statusCode ?? 'ERR')}`;
|
|
245
241
|
}
|
|
246
242
|
}
|
|
247
243
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
248
244
|
}
|
|
249
|
-
function
|
|
250
|
-
const
|
|
251
|
-
(0,
|
|
252
|
-
|
|
245
|
+
function getPageContextHttpResponseError(err, pageContextInit) {
|
|
246
|
+
const pageContextWithError = createPageContext(pageContextInit);
|
|
247
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseError)();
|
|
248
|
+
(0, utils_js_1.objectAssign)(pageContextWithError, {
|
|
249
|
+
httpResponse,
|
|
253
250
|
errorWhileRendering: err
|
|
254
251
|
});
|
|
255
|
-
return
|
|
252
|
+
return pageContextWithError;
|
|
256
253
|
}
|
|
257
|
-
function
|
|
258
|
-
const
|
|
259
|
-
(0,
|
|
260
|
-
|
|
261
|
-
|
|
254
|
+
function getPageContextHttpResponseFavicon404(pageContextInit) {
|
|
255
|
+
const pageContext = createPageContext(pageContextInit);
|
|
256
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseFavicon404)();
|
|
257
|
+
(0, utils_js_1.objectAssign)(pageContext, {
|
|
258
|
+
httpResponse
|
|
262
259
|
});
|
|
263
|
-
|
|
260
|
+
(0, utils_js_1.checkType)(pageContext);
|
|
261
|
+
return pageContext;
|
|
264
262
|
}
|
|
265
263
|
function createPageContext(pageContextInit) {
|
|
266
264
|
const pageContext = {
|
|
@@ -331,10 +329,12 @@ function getRequestId() {
|
|
|
331
329
|
(0, utils_js_1.assert)(httpRequestId >= 1);
|
|
332
330
|
return httpRequestId;
|
|
333
331
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
function assertIsUrl(urlOriginal) {
|
|
333
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isUrl)(urlOriginal), `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which isn't a valid URL.`);
|
|
334
|
+
}
|
|
335
|
+
function assertIsNotViteRequest(urlPathname, urlOriginal) {
|
|
336
|
+
const isViteRequest = urlPathname.startsWith('/@vite/client') || urlPathname.startsWith('/@fs/') || urlPathname.startsWith('/__vite_ping');
|
|
337
|
+
(0, utils_js_1.assertUsage)(!isViteRequest, `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which is unexpected because this URL should have already been handled by Vite's development middleware. Make sure to 1. install Vite's development middleware and 2. add Vite's middleware *before* Vike's middleware, see https://vike.dev/renderPage`);
|
|
338
338
|
}
|
|
339
339
|
function normalizeUrl(pageContextInit, httpRequestId) {
|
|
340
340
|
const { trailingSlash, disableUrlNormalization, baseServer } = (0, globalContext_js_1.getGlobalContext)();
|
|
@@ -348,7 +348,7 @@ function normalizeUrl(pageContextInit, httpRequestId) {
|
|
|
348
348
|
if (!urlNormalized)
|
|
349
349
|
return null;
|
|
350
350
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`URL normalized from ${picocolors_1.default.cyan(urlOriginal)} to ${picocolors_1.default.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
|
|
351
|
-
const httpResponse = (0,
|
|
351
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)({ url: urlNormalized, statusCode: 301 }, pageContextInit.urlOriginal);
|
|
352
352
|
const pageContextHttpResponse = createPageContext(pageContextInit);
|
|
353
353
|
(0, utils_js_1.objectAssign)(pageContextHttpResponse, { httpResponse });
|
|
354
354
|
return pageContextHttpResponse;
|
|
@@ -384,7 +384,7 @@ function getPermanentRedirect(pageContextInit, httpRequestId) {
|
|
|
384
384
|
(0, utils_js_1.assert)(urlTarget !== pageContextInit.urlOriginal);
|
|
385
385
|
}
|
|
386
386
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`Permanent redirect defined by your config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
|
|
387
|
-
const httpResponse = (0,
|
|
387
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)({ url: urlTarget, statusCode: 301 }, urlWithoutBase);
|
|
388
388
|
const pageContextHttpResponse = createPageContext(pageContextInit);
|
|
389
389
|
(0, utils_js_1.objectAssign)(pageContextHttpResponse, { httpResponse });
|
|
390
390
|
return pageContextHttpResponse;
|
|
@@ -413,7 +413,7 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
413
413
|
else {
|
|
414
414
|
pageContextSerialized = (0, serializePageContextClientSide_js_1.serializePageContextAbort)(pageContextAbort);
|
|
415
415
|
}
|
|
416
|
-
const httpResponse = await (0,
|
|
416
|
+
const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePageContextJson)(pageContextSerialized);
|
|
417
417
|
const pageContextReturn = { httpResponse };
|
|
418
418
|
return { pageContextReturn };
|
|
419
419
|
}
|
|
@@ -428,7 +428,7 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
428
428
|
if (pageContextAbort._urlRedirect) {
|
|
429
429
|
const pageContextReturn = createPageContext(pageContextInit);
|
|
430
430
|
(0, utils_js_1.objectAssign)(pageContextReturn, pageContextAbort);
|
|
431
|
-
const httpResponse = (0,
|
|
431
|
+
const httpResponse = (0, createHttpResponse_js_1.createHttpResponseRedirect)(pageContextAbort._urlRedirect, (() => {
|
|
432
432
|
const { pathname, searchOriginal } = pageContextNominalPageInit.urlParsed;
|
|
433
433
|
const urlLogical = (0, utils_js_1.createUrlFromComponents)(null, pathname, searchOriginal,
|
|
434
434
|
// The server-side doesn't have access to the hash
|
|
@@ -441,18 +441,13 @@ pageContextNominalPageInit, httpRequestId, renderContext, pageContextErrorPageIn
|
|
|
441
441
|
(0, utils_js_1.assert)(pageContextAbort.abortStatusCode);
|
|
442
442
|
return { pageContextAbort };
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function assertBaseUrl(pageContextInit) {
|
|
445
445
|
const { baseServer } = (0, globalContext_js_1.getGlobalContext)();
|
|
446
446
|
const { urlOriginal } = pageContextInit;
|
|
447
447
|
const { urlWithoutPageContextRequestSuffix } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
|
|
448
448
|
const { hasBaseServer } = (0, utils_js_1.parseUrl)(urlWithoutPageContextRequestSuffix, baseServer);
|
|
449
|
-
|
|
450
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${prettyUrl(urlOriginal)} doesn't start with Base URL ${prettyUrl(baseServer)} (https://vike.dev/base-url)`, httpRequestId, 'info');
|
|
451
|
-
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
452
|
-
return pageContextHttpResponseNull;
|
|
453
|
-
}
|
|
454
|
-
return null;
|
|
449
|
+
(0, utils_js_1.assertUsage)(hasBaseServer, `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which doesn't start with Base URL ${prettyUrl(baseServer)} (https://vike.dev/base-url)`);
|
|
455
450
|
}
|
|
456
451
|
function prettyUrl(url) {
|
|
457
|
-
return picocolors_1.default.
|
|
452
|
+
return picocolors_1.default.code(decodeURI(url));
|
|
458
453
|
}
|