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

Configuring https server results in an exception #92

Open
metalmarker opened this issue May 30, 2023 · 6 comments
Open

Configuring https server results in an exception #92

metalmarker opened this issue May 30, 2023 · 6 comments

Comments

@metalmarker
Copy link

I'm trying to configure Vite (express) to run https on localhost using these methods.

The problem is that when vite-plugin-node is active, I'm getting this error:
`ERROR [Uncaught exception] Cannot read properties of undefined (reading 'readable')

Stack: TypeError: Cannot read properties of undefined (reading 'readable')
at IncomingMessage._read (node:http_incoming:214:19)
at IncomingMessage.Readable.read (node:internal/streams/readable:487:10)
at resume
(node:internal/streams/readable:987:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)`

Perhaps that can be accomplished by writing a custom adapter?

@metalmarker metalmarker changed the title Configuring http server results in an exception Configuring https server results in an exception Jun 20, 2023
@Ami777
Copy link

Ami777 commented Jul 26, 2023

+1

@Gobbo89
Copy link

Gobbo89 commented Jan 30, 2024

Same here, did you find a solution?

@metalmarker
Copy link
Author

Same here, did you find a solution?

Haven't found a clean solution, instead I've used local-ssl-proxy as a workaround.

@ucefkh
Copy link

ucefkh commented Sep 19, 2024

haha this is the only link on the web that references this error and it happens on all isntances of vite 5+

@ucefkh
Copy link

ucefkh commented Sep 19, 2024

I can confirm this bug, once i removed vite plugin node it worked again

@nickhingston
Copy link

Thanks @metalmarker.

Same here, did you find a solution?

Haven't found a clean solution, instead I've used local-ssl-proxy as a workaround.

Done the same, like this in case it helps anyone:

import { defineConfig, loadEnv } from "vite";
import { VitePluginNode } from "vite-plugin-node";
// import mkcert from "vite-plugin-mkcert";
import { exec } from "child_process";



// @ts-expect-error server.https can be boolean - the return type is wrong in vite
export default defineConfig(({ mode }) => {
	
	// Load env file based on `mode` in the current working directory.
	process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };

	if (mode === "development") {
		// seems there are issues with vite-plugin-node and ssl.  Proxy from 9000 to 9001
		// remove when fixed: https://github.com/axe-me/vite-plugin-node/issues/92
		exec("npx local-ssl-proxy --source 9000 --target 9001 --key ./security/key.pem --cert ./security/cert.pem");
	}

	return {
		server: {
			port: mode === "development" ? 9001 : 9000,
			https: false
		},
		build: {

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

5 participants