-
Notifications
You must be signed in to change notification settings - Fork 35
feat: compat with Nitro 3 #852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ import { colors } from 'consola/utils' | |
| import { defu } from 'defu' | ||
| import type { NitroConfig } from 'nitropack' | ||
| import { joinURL } from 'ufo' | ||
| import { join } from 'pathe' | ||
| import { join, basename } from 'pathe' | ||
|
|
||
| import { normalizeFontData } from 'fontless' | ||
| import type { NormalizeFontDataContext } from 'fontless' | ||
|
|
@@ -29,8 +29,8 @@ export async function setupPublicAssetStrategy(options: ModuleOptions['assets'] | |
|
|
||
| // Register font proxy URL for development | ||
| async function devEventHandler(event: H3Event) { | ||
| const filename = event.path.slice(1) | ||
| const url = context.renderedFontURLs.get(event.path.slice(1)) | ||
| const filename = basename(event.path) | ||
| const url = context.renderedFontURLs.get(filename) | ||
| if (!url) { | ||
| throw createError({ statusCode: 404 }) | ||
| } | ||
|
|
@@ -47,7 +47,7 @@ export async function setupPublicAssetStrategy(options: ModuleOptions['assets'] | |
| } | ||
|
|
||
| addDevServerHandler({ | ||
| route: joinURL(nuxt.options.runtimeConfig.app.baseURL || nuxt.options.app.baseURL, context.assetsBaseURL), | ||
| route: joinURL(nuxt.options.runtimeConfig.app.baseURL || nuxt.options.app.baseURL, context.assetsBaseURL, '**'), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incompatible with Nitro 2 🧐 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we also need to update this to |
||
| handler: eventHandler(devEventHandler), | ||
| }) | ||
|
|
||
|
|
@@ -89,6 +89,7 @@ export async function setupPublicAssetStrategy(options: ModuleOptions['assets'] | |
| dir: cacheDir, | ||
| maxAge: ONE_YEAR_IN_SECONDS, | ||
| baseURL: context.assetsBaseURL, | ||
| fallthrough: nuxt.options.dev, | ||
| }], | ||
| ignore: [`!${join(cacheDir, '**/*')}`], | ||
| prerender: { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does h3'sevent.pathgetter include the query string from the request URL?💡 Result:
Yes, the event.path getter in h3 includes the query string from the request URL [1]. In H3, event.path provides the full path of the incoming request, including both the path and the query parameters (for example, "/test?test=123") [1]. However, please note that event.path is deprecated in H3 v2 [2]. It is recommended to use event.url.pathname and event.url.search instead to access the path and query string components separately [2].
Citations:
🏁 Script executed:
Repository: nuxt/fonts
Length of output: 6001
🏁 Script executed:
Repository: nuxt/fonts
Length of output: 874
Strip query strings before deriving the font filename.
event.pathincludes the search string in h3, sobasename(event.path)will miss cached entries for requests likefont.woff2?v=1and 404. Useevent.url.pathname(or stripevent.url.search) here instead.🤖 Prompt for AI Agents