chrome-extension-svelte-boilerplate icon indicating copy to clipboard operation
chrome-extension-svelte-boilerplate copied to clipboard

sockJS being called without port

Open michaeljelly opened this issue 5 years ago • 1 comments

Hey! I have found a bug. My console gets totally filled with Errors from attempts to connect to sockjs via the URL http://localhost/sockjs-node/info?t=1593696074915

image

I've tried a lot of ways to get webpack to be able to set the Port such that sockjs can go via the port I'm using, which is 8000.

devServer: { public: 'localhost:' + env.PORT, public: 'localhost:' + env.PORT, sockHost: 'localhost:' + env.PORT, sockPath: ':' + env.PORT, port: env.PORT, sockPort: env.PORT, proxy: { '/sockjs-node/': 'http://localhost:' + env.PORT } },

From navigating to the correct URL manually, it looks to me like if it could just connect via the port, the issue would be solved.

image

This is my first experience diving somewhat deep into webpack, and there's a whole load of similar-ish issues, but I haven't seen anybody get the "no port in URL" problem resolved just yet. Was hoping you might be able to help :) Extensions seems to still work perfectly well without it, but having all that red in the console stresses me out!

Thanks for making the plugin btw, it's a great help to skip straight to coding in Svelte :)

michaeljelly avatar Jul 02 '20 13:07 michaeljelly

I came across this issue as well. Here is what I did to resolve the issue.

in utils/webserver.js

added some extra config to the server var:

var server = new WebpackDevServer(compiler, {
  hot: true,
  contentBase: path.join(__dirname, '../build'),
  headers: { 'Access-Control-Allow-Origin': '*' },
  public: `localhost:${env.PORT}`,
  disableHostCheck: true,
});

This got rid of all errors in the console for me but your mileage may vary.

adamwhitlock1 avatar Feb 16 '21 20:02 adamwhitlock1