mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
refactor: update unjs dependencies to stable v1 (#9011)
This commit is contained in:
parent
4c8369fbf3
commit
b49f2a8147
@ -352,7 +352,7 @@ export default defineComponent({
|
||||
|
||||
## Directly Calling an API Endpoint
|
||||
|
||||
There are instances where you may need to directly call the API. Nuxt 3 provides a globally available `$fetch` method using [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch) (in addition to `fetch`)
|
||||
There are instances where you may need to directly call the API. Nuxt 3 provides a globally available `$fetch` method using [unjs/ofetch](https://github.com/unjs/ofetch) (in addition to `fetch`)
|
||||
with the same API as the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).
|
||||
|
||||
Using `$fetch` has a number of benefits, including:
|
||||
|
@ -32,12 +32,12 @@ Learn more about the API layer in the [`server/`](/guide/directory-structure/ser
|
||||
|
||||
Nitro allows 'direct' calling of routes via the globally-available `$fetch` helper. This will make an API call to the server if run on the browser, but will directly call the relevant function if run on the server, **saving an additional API call**.
|
||||
|
||||
`$fetch` API is using [ohmyfetch](https://github.com/unjs/ohmyfetch), with key features including:
|
||||
`$fetch` API is using [ofetch](https://github.com/unjs/ofetch), with key features including:
|
||||
|
||||
- Automatic parsing of JSON responses (with access to raw response if needed)
|
||||
- Request body and params are automatically handled, with correct `Content-Type` headers
|
||||
|
||||
For more information on `$fetch` features, check out [ohmyfetch](https://github.com/unjs/ohmyfetch).
|
||||
For more information on `$fetch` features, check out [ofetch](https://github.com/unjs/ofetch).
|
||||
|
||||
## Typed API Routes
|
||||
|
||||
|
@ -11,7 +11,7 @@ Nuxt automatically scans files inside the `~/server/api`, `~/server/routes`, and
|
||||
|
||||
Each file should export a default function defined with `defineEventHandler()`.
|
||||
|
||||
The handler can directly return JSON data, a `Promise` or use `event.res.end()` to send response.
|
||||
The handler can directly return JSON data, a `Promise` or use `event.node.res.end()` to send response.
|
||||
|
||||
::ReadMore{link="https://nitro.unjs.io/guide/introduction/routing" title="Nitro Route Handling Docs"}
|
||||
::
|
||||
@ -57,7 +57,7 @@ Middleware handlers should not return anything (nor close or respond to the requ
|
||||
|
||||
```ts [server/middleware/log.ts]
|
||||
export default defineEventHandler((event) => {
|
||||
console.log('New request: ' + event.req.url)
|
||||
console.log('New request: ' + event.node.req.url)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -41,7 +41,7 @@ type AsyncData<DataT> = {
|
||||
## Params
|
||||
|
||||
* **Url**: The URL to fetch.
|
||||
* **Options (extends [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch) options & [AsyncDataOptions](/api/composables/use-async-data#params))**:
|
||||
* **Options (extends [unjs/ofetch](https://github.com/unjs/ofetch) options & [AsyncDataOptions](/api/composables/use-async-data#params))**:
|
||||
* `method`: Request method.
|
||||
* `query`: Adds query search params to URL using [ufo](https://github.com/unjs/ufo)
|
||||
* `params`: Alias for `query`
|
||||
@ -89,7 +89,7 @@ const { data, pending, error, refresh } = await useFetch('https://api.nuxtjs.dev
|
||||
|
||||
Adding Query Search Params:
|
||||
|
||||
Using the `query` option, you can add search parameters to your query. This option is extended from [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch) and is using [ufo](https://github.com/unjs/ufo) to create the URL. Objects are automatically stringified.
|
||||
Using the `query` option, you can add search parameters to your query. This option is extended from [unjs/ofetch](https://github.com/unjs/ofetch) and is using [unjs/ufo](https://github.com/unjs/ufo) to create the URL. Objects are automatically stringified.
|
||||
|
||||
```ts
|
||||
const param1 = ref('value1')
|
||||
@ -100,7 +100,7 @@ const { data, pending, error, refresh } = await useFetch('https://api.nuxtjs.dev
|
||||
|
||||
Results in `https://api.nuxtjs.dev/mountains?param1=value1¶m2=value2`
|
||||
|
||||
Using [interceptors](https://github.com/unjs/ohmyfetch#%EF%B8%8F-interceptors):
|
||||
Using [interceptors](https://github.com/unjs/ofetch#%EF%B8%8F-interceptors):
|
||||
|
||||
```ts
|
||||
const { data, pending, error, refresh } = await useFetch('/api/auth/login', {
|
||||
|
@ -12,7 +12,7 @@ Within your pages, components, and plugins you can use `useRequestEvent` to acce
|
||||
const event = useRequestEvent()
|
||||
|
||||
// Get the URL
|
||||
const url = event.req.url
|
||||
const url = event.node.req.url
|
||||
```
|
||||
|
||||
::alert{icon=👉}
|
||||
|
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: "$fetch"
|
||||
description: Nuxt uses ohmyfetch to expose globally the $fetch helper for making HTTP requests.
|
||||
description: Nuxt uses ofetch to expose globally the $fetch helper for making HTTP requests.
|
||||
---
|
||||
|
||||
# `$fetch`
|
||||
|
||||
Nuxt uses [ohmyfetch](https://github.com/unjs/ohmyfetch) to expose globally the `$fetch` helper for making HTTP requests within your Vue app or API routes.
|
||||
Nuxt uses [ofetch](https://github.com/unjs/ofetch) to expose globally the `$fetch` helper for making HTTP requests within your Vue app or API routes.
|
||||
|
||||
::ReadMore{link="/getting-started/data-fetching"}
|
||||
::
|
||||
|
@ -11,7 +11,7 @@ Nuxt 3 provides new options for [fetching data from an API](/getting-started/dat
|
||||
|
||||
In Nuxt 2 you might use `@nuxtjs/axios` or `@nuxt/http` to fetch your data - or just the polyfilled global `fetch`.
|
||||
|
||||
In Nuxt 3 you can use a globally available `fetch` method that has the same API as [the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) or `$fetch` method which is using [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch). It has a number of benefits, including:
|
||||
In Nuxt 3 you can use a globally available `fetch` method that has the same API as [the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) or `$fetch` method which is using [unjs/ofetch](https://github.com/unjs/ofetch). It has a number of benefits, including:
|
||||
|
||||
1. It will handle 'smartly' making [direct API calls](/guide/concepts/server-engine#direct-api-calls) if it's running on the server, or making a client-side call to your API if it's running on the client. (It can also handle calling third-party APIs.)
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
"@nuxt-themes/website": "0.1.9",
|
||||
"jiti": "^1.16.0",
|
||||
"nuxt": "^3.0.0-rc.12",
|
||||
"pathe": "^0.3.9",
|
||||
"scule": "^0.3.2",
|
||||
"pathe": "^1.0.0",
|
||||
"scule": "^1.0.0",
|
||||
"untyped": "^0.5.0"
|
||||
},
|
||||
"packageManager": "yarn@3.2.4"
|
||||
|
@ -1 +1 @@
|
||||
export default defineEventHandler(event => `Hello world (${event.req.url.substr(1)}) (Generated at ${new Date().toUTCString()})`)
|
||||
export default defineEventHandler(event => `Hello world (${event.node.req.url.substr(1)}) (Generated at ${new Date().toUTCString()})`)
|
||||
|
@ -64,13 +64,13 @@
|
||||
"markdownlint-cli": "^0.32.2",
|
||||
"nuxi": "workspace:*",
|
||||
"nuxt": "workspace:*",
|
||||
"ohmyfetch": "^0.4.21",
|
||||
"pathe": "^0.3.9",
|
||||
"ofetch": "^1.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"semver": "^7.3.8",
|
||||
"std-env": "^3.3.0",
|
||||
"typescript": "^4.8.4",
|
||||
"ufo": "^0.8.6",
|
||||
"ufo": "^1.0.0",
|
||||
"unbuild": "^0.9.4",
|
||||
"vite": "^3.2.3",
|
||||
"vitest": "^0.25.1",
|
||||
|
@ -14,22 +14,22 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/schema": "3.0.0-rc.13",
|
||||
"c12": "^0.2.13",
|
||||
"c12": "^1.0.1",
|
||||
"consola": "^2.15.3",
|
||||
"defu": "^6.1.0",
|
||||
"globby": "^13.1.2",
|
||||
"hash-sum": "^2.0.0",
|
||||
"ignore": "^5.2.0",
|
||||
"jiti": "^1.16.0",
|
||||
"knitwork": "^0.1.2",
|
||||
"knitwork": "^1.0.0",
|
||||
"lodash.template": "^4.5.0",
|
||||
"mlly": "^0.5.16",
|
||||
"pathe": "^0.3.9",
|
||||
"pkg-types": "^0.3.6",
|
||||
"scule": "^0.3.2",
|
||||
"mlly": "^1.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"pkg-types": "^1.0.1",
|
||||
"scule": "^1.0.0",
|
||||
"semver": "^7.3.8",
|
||||
"unctx": "^2.0.2",
|
||||
"unimport": "^0.7.0",
|
||||
"unimport": "^1.0.0",
|
||||
"untyped": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -24,7 +24,7 @@
|
||||
"@types/flat": "^5.0.2",
|
||||
"@types/mri": "^1.1.1",
|
||||
"@types/semver": "^7",
|
||||
"c12": "^0.2.13",
|
||||
"c12": "^1.0.1",
|
||||
"chokidar": "^3.5.3",
|
||||
"clear": "^0.1.0",
|
||||
"clipboardy": "^3.0.0",
|
||||
@ -35,15 +35,15 @@
|
||||
"execa": "^6.1.0",
|
||||
"flat": "^5.0.2",
|
||||
"giget": "^0.1.7",
|
||||
"h3": "^0.8.6",
|
||||
"h3": "^1.0.1",
|
||||
"jiti": "^1.16.0",
|
||||
"listhen": "^0.3.5",
|
||||
"mlly": "^0.5.16",
|
||||
"mlly": "^1.0.0",
|
||||
"mri": "^1.2.0",
|
||||
"pathe": "^0.3.9",
|
||||
"pathe": "^1.0.0",
|
||||
"perfect-debounce": "^0.1.3",
|
||||
"pkg-types": "^0.3.6",
|
||||
"scule": "^0.3.2",
|
||||
"pkg-types": "^1.0.1",
|
||||
"scule": "^1.0.0",
|
||||
"semver": "^7.3.8",
|
||||
"unbuild": "latest"
|
||||
},
|
||||
|
@ -39,7 +39,7 @@ export default defineNuxtCommand({
|
||||
|
||||
const serveFile = (filePath: string) => lazyEventHandler(async () => {
|
||||
const contents = await fsp.readFile(filePath, 'utf-8')
|
||||
return eventHandler((event) => { event.res.end(contents) })
|
||||
return eventHandler((event) => { event.node.res.end(contents) })
|
||||
})
|
||||
|
||||
console.warn('Do not deploy analyze results! Use `nuxi build` before deploying.')
|
||||
|
@ -17,7 +17,7 @@ export default defineBuildConfig({
|
||||
dependencies: [
|
||||
'nuxi',
|
||||
'vue-router',
|
||||
'ohmyfetch'
|
||||
'ofetch'
|
||||
],
|
||||
externals: [
|
||||
'@vue/reactivity',
|
||||
|
@ -53,25 +53,25 @@
|
||||
"estree-walker": "^3.0.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"globby": "^13.1.2",
|
||||
"h3": "^0.8.6",
|
||||
"h3": "^1.0.1",
|
||||
"hash-sum": "^2.0.0",
|
||||
"hookable": "^5.4.1",
|
||||
"knitwork": "^0.1.2",
|
||||
"knitwork": "^1.0.0",
|
||||
"magic-string": "^0.26.7",
|
||||
"mlly": "^0.5.16",
|
||||
"nitropack": "^0.6.1",
|
||||
"mlly": "^1.0.0",
|
||||
"nitropack": "^1.0.0-0",
|
||||
"nuxi": "3.0.0-rc.13",
|
||||
"ohash": "^0.1.5",
|
||||
"ohmyfetch": "^0.4.21",
|
||||
"pathe": "^0.3.9",
|
||||
"ohash": "^1.0.0",
|
||||
"ofetch": "^1.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"perfect-debounce": "^0.1.3",
|
||||
"scule": "^0.3.2",
|
||||
"strip-literal": "^0.4.2",
|
||||
"ufo": "^0.8.6",
|
||||
"scule": "^1.0.0",
|
||||
"strip-literal": "^1.0.0",
|
||||
"ufo": "^1.0.0",
|
||||
"ultrahtml": "^1.0.0",
|
||||
"unctx": "^2.0.2",
|
||||
"unenv": "^0.6.2",
|
||||
"unimport": "^0.7.0",
|
||||
"unimport": "^1.0.0",
|
||||
"unplugin": "^0.10.2",
|
||||
"untyped": "^0.5.0",
|
||||
"vue": "^3.2.45",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { FetchError, FetchOptions } from 'ohmyfetch'
|
||||
import type { FetchError, FetchOptions } from 'ofetch'
|
||||
import type { TypedInternalResponse, NitroFetchRequest } from 'nitropack'
|
||||
import { computed, unref, Ref, reactive } from 'vue'
|
||||
import type { AsyncDataOptions, _Transform, KeyOfRes, AsyncData, PickFrom } from './asyncData'
|
||||
|
@ -6,7 +6,7 @@ export function useRequestHeaders<K extends string = string> (include: K[]): Rec
|
||||
export function useRequestHeaders (): Readonly<Record<string, string | undefined>>
|
||||
export function useRequestHeaders (include?: any[]) {
|
||||
if (process.client) { return {} }
|
||||
const headers = useNuxtApp().ssrContext?.event.req.headers ?? {}
|
||||
const headers = useNuxtApp().ssrContext?.event.node.req.headers ?? {}
|
||||
if (!include) { return headers }
|
||||
return Object.fromEntries(include.map(key => key.toLowerCase()).filter(key => headers[key]).map(key => [key, headers[key]]))
|
||||
}
|
||||
@ -18,9 +18,9 @@ export function useRequestEvent (nuxtApp: NuxtApp = useNuxtApp()): H3Event {
|
||||
export function setResponseStatus (code: number, message?: string) {
|
||||
const event = process.server && useRequestEvent()
|
||||
if (event) {
|
||||
event.res.statusCode = code
|
||||
event.node.res.statusCode = code
|
||||
if (message) {
|
||||
event.res.statusMessage = message
|
||||
event.node.res.statusMessage = message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// We set __webpack_public_path via this import with webpack builder
|
||||
import { createSSRApp, createApp, nextTick } from 'vue'
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
import { $fetch } from 'ofetch'
|
||||
// @ts-ignore
|
||||
import { baseURL } from '#build/paths.mjs'
|
||||
import { createNuxtApp, applyPlugins, normalizePlugins, CreateOptions } from '#app'
|
||||
|
@ -10,7 +10,7 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
||||
|
||||
// Create an error object
|
||||
const errorObject = {
|
||||
url: event.req.url,
|
||||
url: event.node.req.url,
|
||||
statusCode,
|
||||
statusMessage,
|
||||
message,
|
||||
@ -21,9 +21,9 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
||||
}
|
||||
|
||||
// Set response code and message
|
||||
event.res.statusCode = (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500
|
||||
event.node.res.statusCode = (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500
|
||||
if (errorObject.statusMessage) {
|
||||
event.res.statusMessage = errorObject.statusMessage
|
||||
event.node.res.statusMessage = errorObject.statusMessage
|
||||
}
|
||||
// Console output
|
||||
if (error.unhandled || error.fatal) {
|
||||
@ -39,13 +39,13 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
||||
|
||||
// JSON response
|
||||
if (isJsonRequest(event)) {
|
||||
event.res.setHeader('Content-Type', 'application/json')
|
||||
event.res.end(JSON.stringify(errorObject))
|
||||
event.node.res.setHeader('Content-Type', 'application/json')
|
||||
event.node.res.end(JSON.stringify(errorObject))
|
||||
return
|
||||
}
|
||||
|
||||
// HTML response (via SSR)
|
||||
const isErrorPage = event.req.url?.startsWith('/__nuxt_error')
|
||||
const isErrorPage = event.node.req.url?.startsWith('/__nuxt_error')
|
||||
const res = !isErrorPage
|
||||
? await useNitroApp().localFetch(withQuery(joinURL(useRuntimeConfig().app.baseURL, '/__nuxt_error'), errorObject), {
|
||||
headers: getRequestHeaders(event) as Record<string, string>,
|
||||
@ -64,8 +64,8 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
||||
// TODO: Support `message` in template
|
||||
(errorObject as any).description = errorObject.message
|
||||
}
|
||||
event.res.setHeader('Content-Type', 'text/html;charset=UTF-8')
|
||||
event.res.end(template(errorObject))
|
||||
event.node.res.setHeader('Content-Type', 'text/html;charset=UTF-8')
|
||||
event.node.res.end(template(errorObject))
|
||||
return
|
||||
}
|
||||
|
||||
@ -74,12 +74,12 @@ export default <NitroErrorHandler> async function errorhandler (error: H3Error,
|
||||
}
|
||||
|
||||
if (res.status && res.status !== 200) {
|
||||
event.res.statusCode = res.status
|
||||
event.node.res.statusCode = res.status
|
||||
}
|
||||
|
||||
if (res.statusText) {
|
||||
event.res.statusMessage = res.statusText
|
||||
event.node.res.statusMessage = res.statusText
|
||||
}
|
||||
|
||||
event.res.end(await res.text())
|
||||
event.node.res.end(await res.text())
|
||||
}
|
||||
|
@ -119,20 +119,20 @@ const PRERENDER_NO_SSR_ROUTES = new Set(['/index.html', '/200.html', '/404.html'
|
||||
|
||||
export default defineRenderHandler(async (event) => {
|
||||
// Whether we're rendering an error page
|
||||
const ssrError = event.req.url?.startsWith('/__nuxt_error')
|
||||
const ssrError = event.node.req.url?.startsWith('/__nuxt_error')
|
||||
? getQuery(event) as Exclude<NuxtApp['payload']['error'], Error>
|
||||
: null
|
||||
if (ssrError && event.req.socket.readyState !== 'readOnly' /* direct request */) {
|
||||
if (ssrError && event.node.req.socket.readyState !== 'readOnly' /* direct request */) {
|
||||
throw createError('Cannot directly render error page!')
|
||||
}
|
||||
|
||||
let url = ssrError?.url as string || event.req.url!
|
||||
let url = ssrError?.url as string || event.node.req.url!
|
||||
|
||||
// Whether we are rendering payload route
|
||||
const isRenderingPayload = PAYLOAD_URL_RE.test(url)
|
||||
if (isRenderingPayload) {
|
||||
url = url.substring(0, url.lastIndexOf('/')) || '/'
|
||||
event.req.url = url
|
||||
event.node.req.url = url
|
||||
if (process.env.prerender && PAYLOAD_CACHE!.has(url)) {
|
||||
return PAYLOAD_CACHE!.get(url)
|
||||
}
|
||||
@ -148,7 +148,7 @@ export default defineRenderHandler(async (event) => {
|
||||
runtimeConfig: useRuntimeConfig() as NuxtSSRContext['runtimeConfig'],
|
||||
noSSR:
|
||||
!!(process.env.NUXT_NO_SSR) ||
|
||||
!!(event.req.headers['x-nuxt-no-ssr']) ||
|
||||
!!(event.node.req.headers['x-nuxt-no-ssr']) ||
|
||||
routeOptions.ssr === false ||
|
||||
(process.env.prerender ? PRERENDER_NO_SSR_ROUTES.has(url) : false),
|
||||
error: !!ssrError,
|
||||
@ -247,8 +247,8 @@ export default defineRenderHandler(async (event) => {
|
||||
// Construct HTML response
|
||||
const response: RenderResponse = {
|
||||
body: renderHTMLDocument(htmlContext),
|
||||
statusCode: event.res.statusCode,
|
||||
statusMessage: event.res.statusMessage,
|
||||
statusCode: event.node.res.statusCode,
|
||||
statusMessage: event.node.res.statusMessage,
|
||||
headers: {
|
||||
'Content-Type': 'text/html;charset=UTF-8',
|
||||
'X-Powered-By': 'Nuxt'
|
||||
@ -304,8 +304,8 @@ async function renderInlineStyles (usedModules: Set<string> | string[]) {
|
||||
function renderPayloadResponse (ssrContext: NuxtSSRContext) {
|
||||
return <RenderResponse> {
|
||||
body: `export default ${devalue(splitPayload(ssrContext).payload)}`,
|
||||
statusCode: ssrContext.event.res.statusCode,
|
||||
statusMessage: ssrContext.event.res.statusMessage,
|
||||
statusCode: ssrContext.event.node.res.statusCode,
|
||||
statusMessage: ssrContext.event.node.res.statusMessage,
|
||||
headers: {
|
||||
'content-type': 'text/javascript;charset=UTF-8',
|
||||
'x-powered-by': 'Nuxt'
|
||||
|
@ -18,22 +18,22 @@
|
||||
"@types/semver": "^7",
|
||||
"@vitejs/plugin-vue": "^3.2.0",
|
||||
"@vueuse/head": "~1.0.0-rc.14",
|
||||
"nitropack": "^0.6.1",
|
||||
"nitropack": "^1.0.0-0",
|
||||
"unbuild": "latest",
|
||||
"vite": "~3.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"c12": "^0.2.13",
|
||||
"c12": "^1.0.1",
|
||||
"create-require": "^1.1.1",
|
||||
"defu": "^6.1.0",
|
||||
"jiti": "^1.16.0",
|
||||
"pathe": "^0.3.9",
|
||||
"pkg-types": "^0.3.6",
|
||||
"pathe": "^1.0.0",
|
||||
"pkg-types": "^1.0.1",
|
||||
"postcss-import-resolver": "^2.0.0",
|
||||
"scule": "^0.3.2",
|
||||
"scule": "^1.0.0",
|
||||
"std-env": "^3.3.0",
|
||||
"ufo": "^0.8.6",
|
||||
"unimport": "^0.7.0",
|
||||
"ufo": "^1.0.0",
|
||||
"unimport": "^1.0.0",
|
||||
"untyped": "^0.5.0"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -20,8 +20,8 @@
|
||||
"execa": "^6.1.0",
|
||||
"get-port-please": "^2.6.1",
|
||||
"jiti": "^1.16.0",
|
||||
"ohmyfetch": "^0.4.21",
|
||||
"pathe": "^0.3.9"
|
||||
"ofetch": "^1.0.0",
|
||||
"pathe": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"playwright": "^1.27.1",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { resolve } from 'node:path'
|
||||
import { execa } from 'execa'
|
||||
import { getRandomPort, waitForPort } from 'get-port-please'
|
||||
import { fetch as _fetch, $fetch as _$fetch, FetchOptions } from 'ohmyfetch'
|
||||
import { fetch as _fetch, $fetch as _$fetch, FetchOptions } from 'ofetch'
|
||||
import * as _kit from '@nuxt/kit'
|
||||
import { useTestContext } from './context'
|
||||
|
||||
|
@ -30,23 +30,23 @@
|
||||
"esbuild": "^0.15.13",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"estree-walker": "^3.0.1",
|
||||
"externality": "^0.2.2",
|
||||
"externality": "^1.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"get-port-please": "^2.6.1",
|
||||
"h3": "^0.8.6",
|
||||
"knitwork": "^0.1.2",
|
||||
"h3": "^1.0.1",
|
||||
"knitwork": "^1.0.0",
|
||||
"magic-string": "^0.26.7",
|
||||
"mlly": "^0.5.16",
|
||||
"ohash": "^0.1.5",
|
||||
"pathe": "^0.3.9",
|
||||
"mlly": "^1.0.0",
|
||||
"ohash": "^1.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"perfect-debounce": "^0.1.3",
|
||||
"pkg-types": "^0.3.6",
|
||||
"pkg-types": "^1.0.1",
|
||||
"postcss": "^8.4.19",
|
||||
"postcss-import": "^15.0.0",
|
||||
"postcss-url": "^10.1.3",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-visualizer": "^5.8.3",
|
||||
"ufo": "^0.8.6",
|
||||
"ufo": "^1.0.0",
|
||||
"unplugin": "^0.10.2",
|
||||
"vite": "~3.2.3",
|
||||
"vite-node": "^0.25.1",
|
||||
|
@ -112,13 +112,13 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
const viteRoutes = viteServer.middlewares.stack.map(m => m.route).filter(r => r.length > 1)
|
||||
const viteMiddleware = defineEventHandler(async (event) => {
|
||||
// Workaround: vite devmiddleware modifies req.url
|
||||
const originalURL = event.req.url!
|
||||
const originalURL = event.node.req.url!
|
||||
if (!viteRoutes.some(route => originalURL.startsWith(route)) && !originalURL.startsWith(clientConfig.base!)) {
|
||||
event.req.url = joinURL('/__url', originalURL)
|
||||
event.node.req.url = joinURL('/__url', originalURL)
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
viteServer.middlewares.handle(event.req, event.res, (err: Error) => {
|
||||
event.req.url = originalURL
|
||||
viteServer.middlewares.handle(event.node.req, event.node.res, (err: Error) => {
|
||||
event.node.req.url = originalURL
|
||||
return err ? reject(err) : resolve(null)
|
||||
})
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Agent as HTTPSAgent } from 'node:https'
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
||||
|
||||
|
@ -117,7 +117,7 @@ function createViteNodeApp (ctx: ViteBuildContext, invalidates: Set<string> = ne
|
||||
}
|
||||
|
||||
return eventHandler(async (event) => {
|
||||
const moduleId = decodeURI(event.req.url!).substring(1)
|
||||
const moduleId = decodeURI(event.node.req.url!).substring(1)
|
||||
if (moduleId === '/') {
|
||||
throw createError({ statusCode: 400 })
|
||||
}
|
||||
|
@ -34,9 +34,9 @@
|
||||
"magic-string": "^0.26.7",
|
||||
"memfs": "^3.4.10",
|
||||
"mini-css-extract-plugin": "^2.6.1",
|
||||
"mlly": "^0.5.16",
|
||||
"ohash": "^0.1.5",
|
||||
"pathe": "^0.3.9",
|
||||
"mlly": "^1.0.0",
|
||||
"ohash": "^1.0.0",
|
||||
"pathe": "^1.0.0",
|
||||
"pify": "^6.1.0",
|
||||
"postcss": "^8.4.19",
|
||||
"postcss-import": "^15.0.0",
|
||||
@ -44,7 +44,7 @@
|
||||
"postcss-url": "^10.1.3",
|
||||
"style-resources-loader": "^1.5.0",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^0.8.6",
|
||||
"ufo": "^1.0.0",
|
||||
"unplugin": "^0.10.2",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue-bundle-renderer": "^0.5.0",
|
||||
|
732
pnpm-lock.yaml
732
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
import { execSync } from 'node:child_process'
|
||||
import { $fetch } from 'ohmyfetch'
|
||||
import { $fetch } from 'ofetch'
|
||||
import { inc } from 'semver'
|
||||
import { loadWorkspace } from './_utils'
|
||||
|
||||
|
@ -9,7 +9,8 @@ import { expectNoClientErrors, renderPage, withLogs } from './utils'
|
||||
await setup({
|
||||
rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
|
||||
server: true,
|
||||
browser: true
|
||||
browser: true,
|
||||
setupTimeout: (isWindows ? 240 : 120) * 1000
|
||||
})
|
||||
|
||||
describe('server api', () => {
|
||||
|
@ -62,14 +62,13 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
||||
"@vueuse/shared",
|
||||
"buffer-from",
|
||||
"cookie-es",
|
||||
"defu",
|
||||
"destr",
|
||||
"estree-walker",
|
||||
"h3",
|
||||
"hookable",
|
||||
"node-fetch-native",
|
||||
"ofetch",
|
||||
"ohash",
|
||||
"ohmyfetch",
|
||||
"pathe",
|
||||
"radix3",
|
||||
"scule",
|
||||
|
4
test/fixtures/basic/types.ts
vendored
4
test/fixtures/basic/types.ts
vendored
@ -3,12 +3,12 @@ import { describe, it } from 'vitest'
|
||||
import type { Ref } from 'vue'
|
||||
import type { AppConfig } from '@nuxt/schema'
|
||||
|
||||
import type { FetchError } from 'ohmyfetch'
|
||||
import type { FetchError } from 'ofetch'
|
||||
import { NavigationFailure, RouteLocationNormalizedLoaded, RouteLocationRaw, useRouter as vueUseRouter } from 'vue-router'
|
||||
import { defineNuxtConfig } from '~~/../../../packages/nuxt/config'
|
||||
import type { NavigateToOptions } from '~~/../../../packages/nuxt/dist/app/composables/router'
|
||||
// eslint-disable-next-line import/order
|
||||
import { isVue3 } from '#app'
|
||||
import { defineNuxtConfig } from '~~/../../../packages/nuxt/config'
|
||||
import { useRouter } from '#imports'
|
||||
|
||||
interface TestResponse { message: string }
|
||||
|
Loading…
Reference in New Issue
Block a user