static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

Route rewrite removes Query Parameters

Open JyrgCodes opened this issue 10 months ago • 0 comments

Before filing this issue, please ensure you're using the latest CLI by running swa --version and comparing to the latest version on npm.

Are you accessing the CLI from the default port :4280 ?

  • [ ] No, I am using a different port number (--port) and accessing the CLI from that port
  • [x] Yes, I am accessing the CLI from port :4280

Make sure you are accessing the URL printed in the console when running swa start!

ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug When defining a route rewrite in the staticwebapp.config.json like this:

{
  "routes": [
    {
      "route": "/something",
      "rewrite": "/api/something"
    }
}

The query parameters are not passed to the rewritten route.

To Reproduce Steps to reproduce the behavior:

  1. Create a route as described above
  2. In the API endpoint something log the query parameters from the request
  3. Run npx swa start public --api-location http://localhost:7071
  4. Request http://localhost:4280/something?key=value
  5. Notice in API logs that no query parameters arrive

Expected behavior The query parameters from the initial request are available in the API.

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

JyrgCodes avatar Feb 16 '25 14:02 JyrgCodes