FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

The route "..." does not exist - only in prod environment #301

Closed cyrnm closed 6 years ago

cyrnm commented 6 years ago

Hello,

I have been successfully using this great bundle while developing my application. However, today I started GUI-testing on several devices and used the production environment for basically the first time, noticing some weird behavior. The Routing and the Routing bundle work perfectly in dev environment, but in production calling, for example, http://url/details/digital which is a route set up like

masonry: path: /details/{slug} defaults: _controller: AppBundle:Masonry:index slug: '' options: expose: true

in routing.yml produces these errors in my Chrome console:

GET http://sdsa.local/js/routing?callback=fos.Router.setData net::ERR_ABORTED jquery-3.2.1.min.js:2 Uncaught Error: The route "masonry" does not exist. at K.f.i (router.js:9) at K.f.m (router.js:10) at generateRoute (scripts.min.js:18) at HTMLDocument. (scripts.min.js:18) at j (jquery-3.2.1.min.js:2) at k (jquery-3.2.1.min.js:2)

I followed the documentation setup and have that passage in my routing.yml:

fos_js_routing: resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

as well as the scripts in my base.html.twig, which is being extended by every single view I have:

<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script><script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>

I'm generating the routes in my Javascript via

var route = Routing.generate('masonry', {slug: slug});

where slug is the variable containing a string so I can generate routes dynamically.

I couldn't find anyone experiencing the same issue (only in production) and have tried some solutions people stated that described the same issue, but in general. I would appreciate some pointers.

Best regards

Edit: the command php bin/console fos:js-routing:debug --env=prod returns all routes I defined with expose: true correctly.

cyrnm commented 6 years ago

Apparently this problem didn't have anything to do with the bundle itself, but with several permissions, where the server lost ownership of cache-files when clearing the cache...