Last active
June 27, 2020 11:51
-
-
Save jimmyadaro/c0be14a8484e6d42b73ef9d44deaaba7 to your computer and use it in GitHub Desktop.
Gulp with local HTTPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you're using XAMPP on macOS, you can use "Secure-Vhost" | |
// @link: https://github.com/jimmyadaro/secure-vhost | |
var local_dev_url = "my-site.local", | |
path_to_local_dev_key = "/path/to/Secure-Vhost/"+local_dev_url+"/cert.key", | |
path_to_local_dev_cert = "/path/to/Secure-Vhost/"+local_dev_url+"/cert.crt"; | |
// ... | |
browserSync.init({ | |
open: 'external', | |
host: local_dev_url, | |
proxy: "https://"+local_dev_url, | |
port: 8888, | |
https: { | |
key: path_to_local_dev_key, | |
cert: path_to_local_dev_cert | |
}, | |
// Add a nonce to the browserSync script tag | |
// You can add that nonce to your CSP (Content Security Policy) | |
// Example: "script-src 'self' 'nonce-browser-sync'" | |
snippetOptions: { | |
rule: { | |
match: /<\/head>/i, | |
fn: function (snippet, match) { | |
return snippet.replace('id=', `nonce="browser-sync" id=`) + match; | |
} | |
} | |
} | |
}); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment