question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browsersync + Laravel Valet Secure

See original GitHub issue

Im using browser-sync to serve up my local dev sites. Im also using Laravel Valet. When I use valet secure to serve a dev site over https, Im getting those ugly Chrome Privacy Error pages. Is there a way to stop this?

My browser-sync config is as follows:

    browserSync.init({
	    host: "https://mysite.dev",
            proxy: "https://mysite.dev",
            ...

mysite.dev changes from site to site, I have a lot of local dev sites Im working on.

When I run npm start browser-sync outputs this:

    [BS] Proxying: https://mysite.dev
    [BS] Access URLs:
    ------------------------------------------
          Local: https://localhost:3000
       External: https://https://mysite.dev:3000
     ------------------------------------------
             UI: http://localhost:3001
    UI External: http://https:3001

As you can see its correctly mapping the URL, and if I ignore Chromes privacy error warnings I can see the website fine. Im just wondering why the https is not working properly.

If I access https://mysite.dev without browser-syncs :3000 port, it works fine in Chrome, and says “Secure” on the address bar

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
vanderbakecommented, Jan 27, 2020

If you’re using valet secure and want browserSync play nicely with your test domain, here is a snippet which will make it secure without any errors:

// At the top of you webpack.mix.js file
const domain = 'yourdomain.test'; // <== edit this one
const homedir = require('os').homedir();

// The mix script:
mix.browserSync({
      proxy: 'https://' + domain,
      host: domain,
      open: 'external',
      https: {
        key: homedir + '/.valet/Certificates/' + domain + '.key',
        cert: homedir + '/.valet/Certificates/' + domain + '.crt',
      },
  })

This will load “https://yourdomain.test:3000” with valid certificates.

Maybe this helps someone stumbling across this. 😃

4reactions
brianlarsoncommented, Jan 27, 2020

Maybe it has to do with the version of Valet but on my setup (v 2.8.0) the location of the cert and key files is different. Works like a charm though! Goodbye SSL for friggin’ localhost!

https: { key: homedir + '/.config/valet/Certificates/' + domain + '.key', cert: homedir + '/.config/valet/Certificates/' + domain + '.crt', },

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Browsersync with Laravel Valet (2021) | RJS
Browsersync is a tool to make developing easier. It offers handy tools, of which the most important is automatic browser reloading on file ......
Read more >
Laravel Valet not playing nice with BrowserSync - Laracasts
I was having issues getting BrowserSync to play nice with Valet (Caddy server) using HTTPS. Chrome couldn't verify the certificate to the proxy...
Read more >
Browser-sync and Valet Secure - node.js - Stack Overflow
Im using browser-sync to serve up my local dev sites. Im also using Laravel Valet. When I use valet secure to serve a...
Read more >
BrowserSync in Laravel Valet - Sridhar Katakam
BrowserSync in Laravel Valet · Lightweight, super fast, feels native as if part of the OS · Always-on sites with nothing to start/stop...
Read more >
How to setup a Craft CMS project with Laravel Mix (and Vue.js)
MacOS; Laravel Valet (installation instructions) ... valet secure tutorial ... Tailwind CSS (JIT) (compiled from SASS); VueJS support; BrowserSync support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found