Using 'browser-sync' and 'connect-modrewrite'
See original GitHub issueI am working on a angular.js app. My problem is when working locally, when I refresh my URL i get Cannot GET /
when a page is refreshed other than the index.html etc.
My problem is solved on my production server using:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
</IfModule>
However I’d like a solution which works with gulp, locally. I have read you can use ‘connect-modrewrite’ like so:
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: outputDir,
middleware: function() {
return [
modRewrite([
'^/api/v1/(.*)$ http://localhost:3000/api/v1/$1 [P]'
])
];
}
}
});
});
The above doesn’t work, so I assume its incorrect. Am I way off?
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Browsersync options
Browsersync options. These are all the options that you can configure when using Browsersync. Create a single object and pass it as the...
Read more >Browsersync Command Line Usage
First, either install Browsersync globally, or locally to your project (if you're using npm scripts) and then run one of the following commands...
Read more >Browsersync + Gulp.js
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >Browsersync - Time-saving synchronised browser testing
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >Browsersync API
Our API is incredibly simple & powerful. You can use it to create your own tiny node program for local development or integrate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
You can use : connect-modrewrite
npm install --save-dev connect-modrewrite
and in your gulpfile.js :
@FadelChafai Thanks worked perfectly locally with AngularJS ui-Router with
$locationProvider.html5Mode(true);