vue.js - Symfony 3 routes + VueJS's index.html with F5 falls to 404 -
i try connect vue.js symfony 3, have no idea how create proper route configuration it. project tree looks that:
project root - app/ - resources/ - views/ - default/ - web/ - assets/ - static/ index.html // here vue included
from symfony provide rest api, routes prefixed /api/. , have routes in vue spa. problem if press f5 in browser on vue route, of course not included in routing.yml, browser returns 404 error symfony. 1 half-working decision when put content of index.html resourses/views/default/twig such route:
fallback_for_vue: path: /{req} defaults: { _controller: 'appbundle:default:index' } requirements: req: ".+"
,taken question, not need, because don't want frontend programmer go somewhere except web/ folder. configuration of symfony routes should use?
you need wildcard address point vue.js application. otherwise when reload send request symfony, , doesn't know hoy handle it.
vuejs_wildcard_route: defaults: { _controller: appbundle:yourcontroller:youraction } path: /vuejsappbasepath/{whatever} requirements: whatever: .* defaults: whatever: null
i have setup working reactjs app , working perfectly.
yourcontroller controller contains youraction, 1 loads template vue.js panel.
Comments
Post a Comment