Skip to content

Conversation

@xMorthi
Copy link

@xMorthi xMorthi commented Sep 24, 2025

🔗 Linked issue

❓ 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

The azure_functions preset discards query parameters when constructing the
URL passed to nitroApp.localCall. Currently it only uses:

const url = "/" + (req.params.url || "");

As a result, any query string is lost (getQuery(event) always returned {}).

This PR updates the handler to preserve the query portion from req.url
(if present):

let path = "/" + (req.params.url || "");
if (req.url && req.url.includes("?")) {
  path += req.url.slice(req.url.indexOf("?"));
}

📝 Checklist

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

@xMorthi xMorthi requested a review from pi0 as a code owner September 24, 2025 13:17
@vercel
Copy link

vercel bot commented Sep 24, 2025

@xMorthi is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

let url = "/" + (req.params.url || "");

if (req.url && req.url.includes("?")) {
url += req.url.slice(req.url.indexOf("?"));
Copy link
Member

@pi0 pi0 Sep 25, 2025

Choose a reason for hiding this comment

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

Wondering why we are not using req.url in the first place instead of req.params.url? (/cc @danielroe if you remember any of the context)

Copy link
Author

Choose a reason for hiding this comment

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

To my understanding, its because req.url is full urlls https://domain... while req.params.url actually starts from api/

Copy link
Member

@pi0 pi0 Sep 25, 2025

Choose a reason for hiding this comment

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

That's actually a good thing! We can use new URL(req.url) one step + also provide valid host header not sure if it is right or not currently.

Copy link
Author

Choose a reason for hiding this comment

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

I'm already running a few apps on Azure and haven't encountered any issues with accessing headers on the Nitro side. We pass the entire req.headers directly.

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