-
Notifications
You must be signed in to change notification settings - Fork 512
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
fix(openapi): use dynamic host + port #2216
Conversation
src/runtime/routes/openapi.ts
Outdated
@@ -9,6 +10,10 @@ import type { | |||
import { handlersMeta } from "#internal/nitro/virtual/server-handlers"; | |||
import { useRuntimeConfig } from "#internal/nitro"; | |||
|
|||
// Currently, openapi is only available in dev, so there is no runtime difference to be determined here | |||
const port = (destr(process.env.NITRO_PORT || process.env.PORT) || |
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.
The port can be still overriding with config, --port
or as part of fallback.
We might retrieve it from headers inside event handler
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.
@pi0 done, I used the referer
header to get it, so maybe it's a little more accurate
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.
Can we remove the ports inferred from environment variables, this will allow us to support more runtimes in the future ? (if running on production)
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.
Well, I found out that there is an easiest way π€£π€£π€£
const url = getRequestURL(event).origin + base
Thanks to h3
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.
Thanks!
π Linked issue
#2215
β Type of change
π Description
Currently, openapi is only available in dev, so there is no runtime difference to be determined here π₯°
π Checklist