I'm trying to install a Symfony 3.1.4 project on a managed server. It works perfectly on my local machine, but not on the external.
For JS routing I use FOSJsRoutingBundle, version ^1.6
.
Problem:
When I visit http://mydomain.tld
, the browser tries to load http://mydomain.tld/bundles/fosjsrouting/js/router.js
, but is not allowed to: 403 Forbidden
.
For my understanding the file exists, but I'm not allowed to load it.
Solving approach:
php bin/console cache:clear --env=prod
php bin/console fos:js-routing:dump
php bin/console assets:install --symlink web
web/bundles/*
: 755Nothing worked.
Could it be related to the symlinks? I'm a bit lost and. Any ideas?
Thanks in advance!
Edit 1: security.yml
security:
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
remember_me:
secret: '%secret%'
lifetime: 604800
path: /
pattern: ^/
form_login:
provider: fos_userbundle
login_path: fos_user_security_login
check_path: fos_user_security_check
csrf_token_generator: security.csrf.token_manager
logout:
path: fos_user_security_logout
target: index
anonymous: true
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: /admin/, role: ROLE_ADMIN }
- { path: /dashboard, role: ROLE_USER }
答案 0 :(得分:1)
我最近遇到过这个问题,这在Symfony 3.4中对我有用:
在config.yml
中,您需要将一个包添加到资产配置中,并将base_path
设置为/bundles
。这使得路由公开,并且应该允许您从安装的任何捆绑中提取任何资产文件。当然,如果您愿意,可以为每个包添加一个包。
framework:
assets:
packages:
bundles:
base_path: '/bundles'