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

Proxying doesn't work anymore #19494

Closed
7 tasks done
MakarMS opened this issue Feb 22, 2025 · 1 comment
Closed
7 tasks done

Proxying doesn't work anymore #19494

MakarMS opened this issue Feb 22, 2025 · 1 comment

Comments

@MakarMS
Copy link

MakarMS commented Feb 22, 2025

Describe the bug

Hi, my proxying is broken. I understand that after this PR #19234. The same configuration on version 5.2 works fine, but when upgrading to 5.4.14 the connection is not established. If I go to the container IP directly, the connection is established.

Reproduction

https://github.com/MakarMS/vite-bug-reproduction

Steps to reproduce

docker compose up and go to localhost. There will be errors in the console and HMR will not work.

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 AMD Ryzen 5 2400G with Radeon Vega Graphics
    Memory: 35.00 GB / 54.84 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.17.1 - /usr/local/bin/node
    npm: 10.8.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 131.0.6778.264
  npmPackages:
    @vitejs/plugin-vue: ^5.2.1 => 5.2.1 
    vite: ^6.1.0 => 6.1.1

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

This is caused by stripping query params when proxying requests to Vite in nginx.
Removing $uri from proxy_pass or

    location / {
-       proxy_pass http://frontend:5173$uri;
+       proxy_pass http://frontend:5173;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;

adding $is_args$args would work.

    location / {
-       proxy_pass http://frontend:5173$uri;
+       proxy_pass http://frontend:5173$uri$is_args$args;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;

Note that you need to call docker-compose up --build as the image for nginx needs to be built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants