0

I have a vuejs app with the a webpack template https://github.com/vuejs-templates/webpack and I when push to production server I am trying to force it to use https but not when on local.

I could use something like this:

if (location.protocol != 'https:' && location.href != 'localhost')
{
 location.href = 'https:' + window.location.href.substring(window.location.protocol.length);
}

on the main.js file but it seems like a hack. I'm sure webpack providers a way but I can't find it.

hidar
  • 5,449
  • 15
  • 46
  • 70

1 Answers1

1

You have to configure your server to use https only and not webpack.

e.g. https://developer.jboss.org/thread/253008?_sscc=t

Just google for your webserver how to configure it.

user1497119
  • 443
  • 6
  • 19
  • The link doesn't have the answer I am looking for. Also, if I set the server to listen only https, then I would not be able to work from localhost – hidar Oct 27 '17 at 12:46
  • ofc you would not configure your server on localhost same as on production. Or do you want to access your production server via localhost? You could also use something like hotel and use local server with https. https://github.com/typicode/hotel then use e. g. https://my-localhost.dev to get it running. – user1497119 Nov 02 '17 at 10:48