GithubHelp home page GithubHelp logo

Comments (5)

laurencefass avatar laurencefass commented on April 20, 2024

Ive just installed a Vite app and it solves this very problem by providing an HMR configuration which splits the clientport and serverport to enable proxying. a 443 client port works with wss, and any port works for the backend,

https://vitejs.dev/config/#server-hmr

from indie-stack.

laurencefass avatar laurencefass commented on April 20, 2024

I have got this working on port 443 with following configuration.

Using port 443 ensures that the socket port is not explicitly included in the wss:// URL callback from client to server for livereload. Any other port number forces inclusion of the port in the wss URL and breaks proxy addressing. I think 443 is the correct port selection visibile to the client, but using port 443 on the server will cause problems in a multi-instance execution environment. Hence the need to split them.

.env

REMIX_DEV_SERVER_WS_PORT=443

and nginx config:

server {
    listen 80;
    server_name remix1.syntapse.co.uk;
    location / {
        proxy_pass http://0.0.0.0:3300;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    location /socket {
        proxy_pass http://0.0.0.0:443;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

however I expect to run into problems if I try to run multiple instances within a single execution environment so the requirement for a REMIX_DEV_CLIENT_WS_PORT .env var is still viable.

from indie-stack.

kentcdodds avatar kentcdodds commented on April 20, 2024

Hi @laurencefass,

Sorry for not getting to this sooner. I'd say that this is a good use case for forking the stack and making your own. Proxying an app is not common enough for this stack's audience to include in this stack.

from indie-stack.

laurencefass avatar laurencefass commented on April 20, 2024

Thanks for replying. Currently I include myself in this stack's audience and Im trying to use it behind a reverse proxy. Other React frameworks I've trialled (Next, CRA, Vite, Blitz) offer a built-in solution for this use case. Can you elaborate why you dont expect reverse proxying remix apps to access on the web to be a common use case?

from indie-stack.

kentcdodds avatar kentcdodds commented on April 20, 2024

There are three things at play here:

  1. Everyone has different requirements, constraints, and opinions on how they want to build their apps
  2. Everything we add to the stack is cognitive load for people who use the stack
  3. It's very easy to make a custom stack

So even though there are lots of people who do use reverse proxy, most wouldn't need it, so I'd rather just leave that to the people who do need it.

from indie-stack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.