Skip to content

Quary params transformation is not one-to-one #198

@TheStaticTurtle

Description

@TheStaticTurtle

Hi,

django-revproxy does not provide a one-to-one transformation of query parameters.
For example, querying the following url:

  • /src/components/Window.vue?vue&type=style&index=0&scoped=e74fd897&lang.css

is being transformed to:

  • http://127.0.0.1:3000/src/components/Window.vue?vue=&type=style&index=0&scoped=e74fd897&lang.css=

(Note the equal sign at the end)

It's a weird and stupid issue to have, but for some reason, the vitejs dev server returns a different value if the equal sign is present or not.

Right now, I'm fixing it by overriding get_encoded_query_params:

def get_encoded_query_params(self):
     get_data = encode_items(self.request.GET.lists())
     params = urlencode(get_data)
     if params.endswith("lang.css="):
          return params[:-1]
     return params

But this is a very static and specific patch to my issue.

Looking at the source for urlencode however, I don't think there is a way to configure it to not use an equal it's hard-coded to use k + '=' + v

Full logs:

[2025-05-21 11:33:16,907] [revproxy.view] [DEBUG] Dispatch full path: /src/components/Window.vue?vue&type=style&index=0&scoped=e74fd897&lang.css
[2025-05-21 11:33:16,907] [revproxy.view] [DEBUG] Request headers: {'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'Sec-Ch-Ua': '"Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Windows"', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'Sec-Fetch-Site': 'none', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-User': '?1', 'Sec-Fetch-Dest': 'document', 'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8', 'Cookie': 'csrftoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx; sessionid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
[2025-05-21 11:33:16,907] [revproxy.view] [DEBUG] Request URL: http://127.0.0.1:3000/src/components/Window.vue
[2025-05-21 11:33:16,907] [revproxy.view] [DEBUG] Request URL: http://127.0.0.1:3000/src/components/Window.vue?vue=&type=style&index=0&scoped=e74fd897&lang.css=
[2025-05-21 11:33:16,909] [revproxy.view] [DEBUG] Proxy response header: HTTPHeaderDict({'Vary': 'Origin', 'Content-Type': 'text/javascript', 'Cache-Control': 'no-cache', 'Etag': 'W/"a0-1ifrEXfi3rOgXPV8wEobwY9jP8M"', 'Date': 'Wed, 21 May 2025 09:33:16 GMT', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=5', 'Content-Length': '160'})
[2025-05-21 11:33:16,910] [revproxy.view] [DEBUG] RESPONSE RETURNED: <HttpResponse status_code=200, "text/javascript">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions