feat: init
This commit is contained in:
25
node_modules/nuxt/dist/pages/runtime/validate.js
generated
vendored
Normal file
25
node_modules/nuxt/dist/pages/runtime/validate.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createError } from "#app/composables/error";
|
||||
import { defineNuxtRouteMiddleware } from "#app/composables/router";
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
if (!to.meta?.validate) {
|
||||
return;
|
||||
}
|
||||
const result = await Promise.resolve(to.meta.validate(to));
|
||||
if (result === true) {
|
||||
return;
|
||||
}
|
||||
const error = createError({
|
||||
fatal: import.meta.client,
|
||||
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
||||
status: result && (result.status || result.statusCode) || 404,
|
||||
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
||||
statusText: result && (result.statusText || result.statusMessage) || `Page Not Found: ${to.fullPath}`,
|
||||
data: {
|
||||
path: to.fullPath
|
||||
}
|
||||
});
|
||||
if (typeof window !== "undefined") {
|
||||
window.history.pushState({}, "", from.fullPath);
|
||||
}
|
||||
return error;
|
||||
});
|
||||
Reference in New Issue
Block a user