Created
February 16, 2017 10:32
-
-
Save yhuard/b3ab432a3296cdc35affc36adaac761c to your computer and use it in GitHub Desktop.
Browsersync proxy example
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
{ | |
"name": "browsersync-proxy-example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "proxy.js", | |
"scripts": { | |
"start": "node ./proxy.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "MIT", | |
"devDependencies": { | |
"browser-sync": "^2.18.8" | |
} | |
} |
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
const browserSync = require('browser-sync').create(); | |
browserSync.init({ | |
// URL of the website we want to proxy | |
proxy: 'https://webgate.acceptance.ec.europa.eu/multisite/farnet/', | |
// Serve files from local src folder | |
serveStatic: ['src'], | |
// If you want to inject custom files | |
snippetOptions: { | |
rule: { | |
match: /<\/head>/i, | |
fn: function(snippet, match) { | |
return '<link rel="stylesheet" type="text/css" href="/_custom.css"/>' + snippet + match; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment