I recently upgraded my Symfony application from version 5.4 to 6.4. My project uses Webpack Encore and the BazingaJsTranslationBundle to manage translations in JavaScript. In my Twig templates, I load translation files like this:
<script src="{{ path('bazinga_jstranslation_js', { 'domain': 'api' }) }}"></script>`
This works perfectly in all environments except for production (APP_ENV=prod
). When APP_ENV
is set to prod
, the JavaScript translation files are not found, and the request to the bazinga_jstranslation_js route results in a 404 error. Everything works as expected when APP_ENV
is set to anything else, such as dev
, test
, or prod2
.
Here are some details about my setup:
The terminal user must have writing access for ./var/cache. If this fails, the BazingaJsTranslationBundle throws a 404 error.
Source: Github issues.
To solve this, you would need to execute the following command:
chown -R www-data:www-data var/cache