laravel-debugbar: Incompatible with BrowserSync Proxy
I followed the installation steps as per the readme, but kept getting the following error in the console:
Uncaught SyntaxError: Unexpected token ILLEGAL
The line causing there error is:
phpdebugbar.addDataSet({ dataset values here });
I have BrowserSync set up as a proxy server for the built-in php server so I have live CSS injection, but when trying to use BrowserSync with the debugbar I get the error above. Switching to the PHP server port fixes the issue, but then BrowserSync doesn’t work.
Local PHP server:
php -S localhost:8000
Gulp task:
gulp.task('browser-sync', function() {
browserSync({
proxy: "localhost:8000"
});
});
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (1 by maintainers)
Thanks @dan-iway
Since Laravel’s artisan start at localhost:8000 by default, this might help others.
This problem came up again because although the error got fixed in foxy, newer versions of browser-sync no longer use foxy but its own implementation of the rewriteLinks function, which again breaks the escaping.
I finally could fix this by using this proxy configuration for browserSync:
Because the proxy target does not literally match the host nothing gets rewritten when accessing the page on http://localhost:3000. Setting the host in reqHeaders additionally fixes the problem of redirects within laravel not honoring port 3000.
@iforwms Try to use browser-sync v2.11.2 😃