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

Using HTTPS with localhost #2

Open
esalexreyes opened this issue Apr 15, 2021 · 5 comments
Open

Using HTTPS with localhost #2

esalexreyes opened this issue Apr 15, 2021 · 5 comments

Comments

@esalexreyes
Copy link

esalexreyes commented Apr 15, 2021

Hey there, I found a small issue when trying to enable the configuration for https proxying on BrowserSync.

It seems to me that even if you add the https section into the project configuration in webpack.config.js the build procedure just ignores it and uses the default SSL certificates bundled with BrowserSync since in most instances you are using custom SSL certificates, this can lead to localhost giving you an insecure connection warning.

I found that the fix is pretty easy, by just adding the https configuration to the config.base.js under the browserSyncOptions constant. Here are my edits:

In webpack.config.js:

...
browserSync: {
    enable: true, // enable or disable browserSync
    host:   'localhost',
    port:   3600,
    mode:   'proxy', // proxy | server
    server: { baseDir: [ 'public' ] }, // can be ignored if using proxy
    proxy:  'https://example.test',
    // BrowserSync will automatically watch for changes to any files connected to our entry,
    // including both JS and Sass files. We can use this property to tell BrowserSync to watch
    // for other types of files, in this case PHP files, in our project.
    files:  '**/**/**.php',
    reload: true, // Set false to prevent BrowserSync from reloading and let Webpack Dev Server take care of this
    // browse to http://localhost:3000/ during development,
    https: {
        key: '/path-to-cert/localhost.key',
        cert: '/path-to-cert/localhost.crt',
    }
},
...

In config.base.js:

...
const browserSyncOptions = {
    files: projectOptions.browserSync.files,
    host:  projectOptions.browserSync.host,
    port:  projectOptions.browserSync.port,
    https: projectOptions.browserSync.https,
}
...

Probably you may have a more elegant solution in case it's not passed as a parameter. 😅

@dayneh88
Copy link

How did enable/create SSL certificates for localhost? I'm trying to do it in MAMP and it says you can't add SSL certificates to localhost.

@esalexreyes
Copy link
Author

esalexreyes commented Jun 16, 2021

@dayneh88 No idea on that front, I'm using Devilbox as my local environment, but I found this: https://really-simple-ssl.com/knowledge-base/how-to-install-an-ssl-certificate-on-mamp/

I hope it helps. :)

@dayneh88
Copy link

@dayneh88 No idea on that front, I'm using Devilbox as my local environment, but I found this: https://really-simple-ssl.com/knowledge-base/how-to-install-an-ssl-certificate-on-mamp/

I hope it helps. :)

Fantastic! Thanks so much for your help. You haven't had any luck getting @font-face to work with this boilerplate by any chance have you?

@esalexreyes
Copy link
Author

Fantastic! Thanks so much for your help. You haven't had any luck getting @font-face to work with this boilerplate by any chance have you?

@dayneh88 I haven't had any problems using @font-face, however, I haven't used this boilerplate in a while. 😅

@dayneh88
Copy link

Fantastic! Thanks so much for your help. You haven't had any luck getting @font-face to work with this boilerplate by any chance have you?

@dayneh88 I haven't had any problems using @font-face, however, I haven't used this boilerplate in a while. 😅

I'm having massive issues!

Are you able to shed any light on this: #4

I'd forever be in your eternal debt if you could help me out. I'm wracking my brain with this haha.

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

2 participants