openapi in nitro only work in local development do not work when deploy with cloudflare pages
Environment
- nuxt: 3.11.2
- nitro: 2.9.6
- nitro-cloudflare-dev: 0.1.4
Reproduction
- Repo: https://github.com/hoanglinh9955/links
-
my deploy url can not open with end point
/_nitro/scalar/_nitro/swagger/_nitro/openapi.json
Describe the bug
Context
- Openapi url return 404 when access to endpoint
/_nitro/scalar/_nitro/swagger/_nitro/openapi.jsonin production mode - The OpenAPI is available on http://localhost:3000/_nitro/openapi.json
I can access on local mode
Nuxt config file
export default defineNuxtConfig({
devtools: { enabled: true },
nitro: {
preset: "cloudflare-pages",
experimental: {
openAPI: true,
},
},
modules: ["nitro-cloudflare-dev", "@nuxt/ui"]
})
Additional context
No response
Logs
No response
Hi, dear @hoanglinh9955. It is a known limitation as current open API support in nitro is for development only.
Stay tuned, in the future it will be possible to opt-in (and possibly password protection)
Hey @pi0, is there a ticket tracking that feature? I'd also like to enable openapi support in production mode.
For anyone who struggles to activate it in production: I had to add the openAPI config outside the experimantal object too:
nitro: {
openAPI: {
production: "runtime",
meta: {
title: "myApp",
description: "myApp description",
},
},
experimental: {
openAPI: {
production: "runtime",
meta: {
title: "myApp",
description: "myApp description",
},
},
}
Not sure why it behaves this way. If I removed it from experimental it wasn't available under localhost:3000/_swagger, if I didn't add it in the main nitro object it wasn't working in production/_swagger.