Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Proxy in front of multiple entry points results in bad script paths #10516

Closed
7 tasks done
atrauzzi opened this issue Oct 18, 2022 · 2 comments
Closed
7 tasks done

Proxy in front of multiple entry points results in bad script paths #10516

atrauzzi opened this issue Oct 18, 2022 · 2 comments

Comments

@atrauzzi
Copy link

atrauzzi commented Oct 18, 2022

Describe the bug

I'm putting an nginx server in front of a vite project running multiple entrypoints as follows:

    server {
        # ...
        server_name ~^office\.(.*)\.localdev$;
        # ...

        location / {
            # ...
            proxy_pass https://172.17.0.1:5005/Office/;
            # ...
        }
    }

    server {
        # ...
        server_name ~^visitor\.(.*)\.localdev$;
        # ...

        location / {
            # ...
            proxy_pass https://172.17.0.1:5005/Visitor/;
            # ...
        }
    }

    server {
        # ...
        server_name ~^login\.(.*)\.localdev$;
        # ...

        location / {
            # ...
            proxy_pass https://172.17.0.1:5005/Login/;
            # ...
        }
    }

When I navigate to a domain such as: https://login.drschwinn.localdev, I successfully load the root page, but all URLs generated by vite for resources are presumed to be based on being hosted in a subdirectory:

image

Reproduction

https://stackblitz.com/edit/vitejs-vite-r5hbbj

Steps to reproduce

Obviously this requires a local proxy setup, but I've linked an example project with the three entrypoints as a starting point.

Basically take the above project, put any kind of proxy in front of it where a subdomain maps to the subfolder on the vite server.

System Info

Fedora, node, yarn, all the latest, etc etc...

Used Package Manager

yarn

Logs

See bug description. 🙂

Validations


Please note: It may be worth taking this bug into consideration along with #10487 and #9236

@kgosen
Copy link

kgosen commented Oct 28, 2022

Running into this issue as well 🤔

@atrauzzi
Copy link
Author

atrauzzi commented Nov 27, 2022

I tried tinkering around with vite and nginx again today and wasn't able to come up with something that could cover everything necessary. It's left me wondering if the current multiple entrypoint implementation in vite is a bit naive or at least optimistic in how it sets out to do things.

The current multiple entrypoint implementation can produce a subdirectory-based hosting model, but I'd argue that this isn't what people necessarily want when they think of "multiple entrypoints".
Because the hosting model presumes a single unified module-space (for lack of better terms) between all the applications, they aren't truly isolated from one another the way they would be if I were to say for example -- run multiple vite servers.

For my experimentation today, this made it really difficult to come up with a correct reverse proxy configuration that could route requests correctly. Some scripts were prefixed with my entrypoint path, some were prefixed with @, some had no prefix at all.

I'm still stumped on what to do here, I'd still love to be able to run a single vite server to build multiple applications, but I really want to be able to refer to them by DNS rather than by subdirectory...

@vitejs vitejs locked and limited conversation to collaborators May 8, 2023
@sapphi-red sapphi-red converted this issue into discussion #13122 May 8, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants