Skip to content

Commit 4f5fb93

Browse files
committed
fix: prevent duplicate hash generation in Nitro OpenApi
reported in nuxt/content#3134
1 parent 4bf5ed9 commit 4f5fb93

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/setup-node@v4
1515
with:
1616
node-version: '20'
17-
- run: corepack enable
17+
- run: npm i -g --force corepack && corepack enable
1818
- run: pnpm install
1919
- run: pnpm dev:prepare
2020
- run: pnpm test

src/module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ export default defineNuxtModule<ModuleOptions>({
239239
addServerHandler({
240240
method: 'get',
241241
route: '/api/component-meta.json',
242-
handler: resolver.resolve('./runtime/server/api/component-meta.get')
242+
handler: resolver.resolve('./runtime/server/api/component-meta.json.get')
243243
})
244244
addServerHandler({
245245
method: 'get',
246246
route: '/api/component-meta/:component?',
247-
handler: resolver.resolve('./runtime/server/api/component-meta.get')
247+
handler: resolver.resolve('./runtime/server/api/component-meta-component.get')
248248
})
249249
}
250250
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as default } from './component-meta.get'

src/runtime/server/api/component-meta.get.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineEventHandler((event) => {
77
// TODO: Replace via downstream config
88
appendHeader(event, 'Access-Control-Allow-Origin', '*')
99

10-
const componentName = (event.context.params['component?'] || '').replace(/\.json$/, '')
10+
const componentName = (event.context.params?.['component?'] || '').replace(/\.json$/, '')
1111

1212
if (componentName) {
1313
const meta = components[pascalCase(componentName)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as default } from './component-meta.get'

0 commit comments

Comments
 (0)