nitro icon indicating copy to clipboard operation
nitro copied to clipboard

openapi in nitro only work in local development do not work when deploy with cloudflare pages

Open hoanglinh9955 opened this issue 1 year ago • 2 comments

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.json in production mode
  • The OpenAPI is available on http://localhost:3000/_nitro/openapi.json

I can access on local mode image

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

hoanglinh9955 avatar May 06 '24 17:05 hoanglinh9955

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)

pi0 avatar May 07 '24 12:05 pi0

Hey @pi0, is there a ticket tracking that feature? I'd also like to enable openapi support in production mode.

bacongobbler avatar Jun 21 '24 15:06 bacongobbler

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.

martinschilliger avatar Jan 30 '25 09:01 martinschilliger