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

node-custom-server trying to implement https / ssl in DEV mode with no luck #84

Open
drscottlobo opened this issue Feb 9, 2025 · 0 comments

Comments

@drscottlobo
Copy link

drscottlobo commented Feb 9, 2025

Good day! I've got a working version of the node-custom-server up and running, it's great!

But I need to have https/ssl over localhost for my app in development. I have set up https with self-signed certificates using express in the past like the following:

https.createServer(
	{
		key: fs.readFileSync("./certificates/localhost-key.pem"),
		cert: fs.readFileSync("./certificates/localhost.pem"),
	},
	app
	).listen(port, function () {
		console.log("Listening on Port 8000. https://localhost:8000/");
	});

But trying something similar with the vite server setup in the node-custom-server template doesn't seem to work, at least not the way I've tried it. I've tried using @vitejs/plugin-basic-ssl in the vite.config.ts like this:

import { reactRouter } from "@react-router/dev/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import basicSsl from "@vitejs/plugin-basic-ssl";

export default defineConfig(({ isSsrBuild }) => ({
	build: {
		rollupOptions: isSsrBuild
			? {
					input: "./server/app.ts",
			  }
			: undefined,
	},
	plugins: [reactRouter(), tsconfigPaths(), basicSsl()],
}));

As well as tried to add my self-signed certificates from mkcert in the template's server.js file as an option within the vite.createServer call:

const viteDevServer = await import("vite").then((vite) =>
vite.createServer({
		server: {
			middlewareMode: true,
			https: {
				key: fs.readFileSync("./cert/localhost-key.pem"),
				cert: fs.readFileSync("./cert/localhost.pem"),
			},
		},
	})
);

None of these seem to be working? I feel like it's probably something simple I'm missing, and I've looked at the vite docs as well, but no clear answer when using the createServer function.

I would really appreciate any help in this regard, as I am loving the new react-router 7 framework!

@drscottlobo drscottlobo changed the title node-custom-server trying to implement https / ssl with no luck node-custom-server trying to implement https / ssl in DEV mode with no luck Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant