bezoerb / generator-grunt-symfony

[DEPRECATED] Yeoman generator that scaffolds out a Symfony PHP app including Browsersync, various CSS preprocessors, RequireJS, jspm, webpack and Service Worker
33 stars 5 forks source link

BrowserSync Server mishandling routes with dots #205

Open FossPrime opened 7 years ago

FossPrime commented 7 years ago

/recipeingredient/parent/65.html

a route such as that will not go to symfony. Would love comments/documentation on grunt/browserSync.js it's a bit of a mess in there.

related to #192

FossPrime commented 7 years ago

I fixed this on my installation with a custom router (app_node.php) that handles all requests for clarity. I could give some requests to the built in server, but that makes the CLI logs look weird, only returning unrouted static files. The other option is to mimic the logs, which is beside the point.

Once php can handle all routes bin/console server:start will work and the browsersync config can be reduced to almost nothing. This is certainly the way to go.

Most of the php routers out there are quite powerful, all we need is a simple php static file router... I may throw one at composer if no one has a better idea.

FossPrime commented 7 years ago

That solution breaks the service worker... :/

500 (Service Worker Response Error) browser-sync-client.2.11.2.js:1

UPDATE: It's a socket.io component of BrowserSync... meaning we should really not handle that with php, but instead have middleware handle it.

UPDATE2: This dumbed down middleware router does the job... though ServiceWorkers are pain for development... it keeps loading a cache of my javascript when browsersync sends a reload after detecting a change.

                middleware: [
                    function(req, res, next) {
                      var obj = parseurl(req);
                      if ( !/^\/browser-sync/.test(obj.pathname) ) {
                          grunt.bsMiddleware(req, res, next);
                      } else {
                          next();
                      }
                    }
                ]