#Error: HTTP server not available

1 messages · Page 1 of 1 (latest)

unique jungle
#

I'm trying to use Vite's http server mode to serve npm packages from a local /packs dir over the network back to a calling client. However, when I call npm run dev I get this error:

error when starting dev server:
Error: HTTP server not available at CAC.<anonymous> (file:///Users/gauvins/Documents/projects/research/bibin/bibin-http/node_modules/vite/dist/node/cli.js:775:19)

Here is my vite.config.js...

import { defineConfig } from 'vite';
export default defineConfig({
server: {
middlewareMode: 'html',
host: "127.0.0.1".
port: 3001,
configureServer(server) {
server.middlewares.use('/packs', async (ctx, next) => {
if (ctx.path.endsWith('.js')) {
ctx.type = 'application/javascript';
ctx.body = await import('./packs/' + ctx.path);
} else {
await next();
}
});
}
}
});

unique jungle
#

update: removing the middlewareMode property allowed it to work... not sure why.

sharp cape
#

I was having the same problem. In my case the property middlewareMode='disabled'. Removing it solved my problem which sort of makes sense. This would allow some process to be enabled. In your case, I wonder if it was just providing the wrong data format back or was not recognized and therefore was being disabled.