Skip to content
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

Merged
merged 4 commits into from
Mar 15, 2024
Merged

fix(openapi): use dynamic host + port #2216

merged 4 commits into from
Mar 15, 2024

Conversation

markthree
Copy link
Contributor

@markthree markthree commented Mar 4, 2024

πŸ”— Linked issue

#2215

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Currently, openapi is only available in dev, so there is no runtime difference to be determined here πŸ₯°

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -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) ||
Copy link
Member

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

Copy link
Contributor Author

@markthree markthree Mar 5, 2024

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

Copy link
Contributor Author

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)

Copy link
Contributor Author

@markthree markthree Mar 5, 2024

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

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 changed the title fix(openapi): dynamically using port fix(openapi): use dynamic host + port Mar 15, 2024
@pi0 pi0 merged commit 985a489 into unjs:main Mar 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants