#request.url has the wrong port number in vite dev mode

1 messages · Page 1 of 1 (latest)

hearty zenith
#

Has anybody seen this before? I’m running remix vite dev on port 5173 and angular dev (also vite based) on port 4200. My remix loaders have the correct request.url.pathname but the request.url.port is 4200, like the angular app. Is it a conflict from running two vite dev servers in parallel?

rancid lintel
#

if you only run one app at the same time, does the Remix app receives the correct port?

hearty zenith
#

Nope still doesn't work. I tried running the Remix app and a separate non-Node non-Vite based static file server and inside of Remix's loaders the request.url.port was still incorrect.

#

I think I figured out the issue though.

My vite remix server is at port 5173. My other app is at port 2015. When I make a request from the second browser app to the remix server, here is what the request headers look like:

Host:
localhost:5173
Origin:
http://localhost:2015

In the remix server loader, request.url.port should be 5173, However, it looks like the remix vite dev adapter actually uses the origin header first, which has the wrong port.

https://github.com/remix-run/remix/blob/2f9b39fb8ff335ca36914769e9b84fe1cc197481/packages/remix-dev/vite/node/adapter.ts#L36

I guess this makes sense for remix client <-> server communication because both the Host and Origin headers have the same port number so it wouldn't really matter. But if you have multiple apps on different servers only the Host header has the correct port.

I'm going to try to write up a proper bug report for this.

GitHub

Build Better Websites. Create modern, resilient user experiences with web fundamentals. - remix-run/remix