-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
LiveReload doesn't work when TLS is enabled #2859
Comments
@isaacs this might help. I'm running a different setup than yours, but I still serve the client via HTTPS and the live reload server has to connect via Heres the actual full client deployment file apiVersion: apps/v1
kind: Deployment
metadata:
name: client-depl
spec:
replicas: 1
selector:
matchLabels:
app: client
template:
metadata:
labels:
app: client
spec:
automountServiceAccountToken: false
containers:
- name: client
image: pidgeon/client-remix
envFrom:
- secretRef:
name: dotenv
# ----------------------------------------------------------------------------------------
#
# Development only
#
# We use init containers to download the root certificate authority certificate,
# that was used to sign the intermediate and leaf certificate of Traefik,
# and mount the certificate to the client's container as NODE_EXTRA_CA_CERTS
#
# We need to do this because otherwise any HTTPS requests issued from the client to Traefik will fail
# ----------------------------------------------------------------------------------------
env:
- name: NODE_EXTRA_CA_CERTS
value: /certs/pebble-root-ca.pem
- name: REMIX_DEV_SERVER_WS_PORT
value: "3001"
volumeMounts:
- name: certs
mountPath: /certs
initContainers:
# ------------------------------------------
#
# Stage 1: Wait for Pebble to be available
#
# ------------------------------------------
- name: client-wait-for-pebble
image: alpine/curl
command: ["/bin/sh", "-c"]
args:
[
'while [[ "$(curl --insecure -s -o /dev/null -w %{http_code} https://pebble:15000/roots/0)" != "200" ]]; do echo "Waiting for Pebble..."; sleep 5; done',
]
# ----------------------------------------------------------------------------------------
#
# Stage 2: Get the root CA used to sign Traefik's leaf and intermediate certificate
#
# ----------------------------------------------------------------------------------------
- name: client-get-root-certs
image: alpine/curl
command: ["/bin/sh", "-c"]
args:
[
"curl --insecure -s -o /certs/pebble-root-ca.pem https://pebble:15000/roots/0",
]
volumeMounts:
- name: certs
mountPath: /certs
volumes:
- name: certs
emptyDir: {} For my case, I use init containers to extend the certificate authorities, via |
Being able to run a |
Is there any chance of the above commit being accepted in the near future? Using Not sure if there's another known workaround. |
Have you tried simply including the remix/packages/remix-react/components.tsx Lines 1498 to 1561 in 40a7a39
|
I've been using
Additionally as this is an organisation repository, editing the library files directly probably wouldn't be a maintainable approach going forward. Appreciate the suggestion though 🙇♂️ |
First, I wasn't saying to edit the Remix version, but to copy it into your project. It's a very straightforward component. I have custom LiveReload as well. However, it doesn't look like you can connect to an insecure web socket from a secure route anyway, so this is a moot point. Is there a reason you need HTTPS on your local machine? Have you considered running a reverse proxy like nginx in front of your Remix app? That way Remix doesn't care about HTTPS, only your browser. |
I made this change for gitpod.io env, and it started working flawlessly.
You can do the same easily with the protocols :) |
@kiliman I need HTTPS for Marketo which requires a custom domain for certain functions to work (for security reasons). If I use a custom domain for localhost without HTTPS on my computer the page won't load because it is not secure. |
@petomalina I had to do a similar thing for CodeSandbox. If you look at my |
Doesn't seem like #4123 or #4107 will be merged anytime soon... so I solved it using the attached snippet. The below connects to the web socket created when calling "remix watch" command, and spins up an Once a message to the remix web socket is sent, it is then sent to the https one. const { WebSocket } = require("ws");
const httpsServer = // ... [some code that spins up an https server with express]
if (NODE_ENV !== "production") {
const connectToRemixSocket = (cb, attempts = 0) => {
const remixSocket = new WebSocket(`ws://127.0.0.1:8002`);
remixSocket.once("open", () => {
console.log("Connected to remix dev socket");
cb(null, remixSocket);
});
remixSocket.once("error", (error) => {
if (attempts < 3) {
setTimeout(() => {
connectToRemixSocket(cb, attempts += 1);
}, 1000);
}
else {
cb(error, null);
}
});
};
connectToRemixSocket((error, remixSocket) => {
if (error) {
throw error;
}
const customSocket = new WebSocket.Server({ server: httpsServer });
remixSocket.on("message", (message) => {
customSocket.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.send(message.toString());
}
});
});
});
} NOTE: app/root.tsx: <body>
....
{/* assuming the https server is listening on port 2001 */}
<LiveReload port={2001} />
</body> |
The new v2 dev server now fully supports TLS, as described in the docs. |
Use Vite and you don't need LiveReload 🙏💯🙌 |
What version of Remix are you using?
1.3.5
Steps to Reproduce
Create a server with TLS keys
Attach remix route handler to it
Load site
Error appears in console:
Change files, observe that they are not reloaded live. (Server rebuilds, but the ws push doesn't work.)
Expected Behavior
Expect that WebSocket.Server would be able to listen over https somehow.
Actual Behavior
Tracked it down to this bit in
./node_modules/@remix-run/dev/cli/commands.js
It appears that the only way for a ws server to speak tls is to attach to an existing server.
Something like this:
The text was updated successfully, but these errors were encountered: