I'm using Symfony 7.1 and EasyAdminBundle to list entities as tables and filter them.I have deployed the whole app to Heroku, which works absolutely fine.
The only problem is:Some url-routes are generated with the scheme 'https' others with 'http'
In explicitly: Links to CrudControllers have 'https' but some requests which are proceeded via javascript have 'http'
For instance, if I use a CrodController and define a filter, this filter-url (...?crudAction=renderFilters ...
) is generated with the scheme 'http':
http://my-app.herokuapp.com/admin?crudAction=renderFilters&crudControllerFqcn...
This causes a CORS Error, meaning, the request fails due to the policy strict-origin-when-cross-origin
What I have tried so far ...
Set the following in the config/packages/routing.yaml (and config/
parameters: router: request_context.scheme: https
Tried to change setting in
config/packages/security.yaml
, explained here: https://symfony.com/doc/current/security/force_https.htmlTried to change
config/routes.yaml
to:controllers: resource: path: ../src/Controller/ namespace: App\Controller type: attribute schemes: [https] # this last line is added
But this only causes the app to redirect to the same url all the time. The routes then break. (too many redirects)
Well, none of them really worked.So I'm really stuck on that problem.
The only idea that I had while debugging was: To generate a patch for the EasyAdmin Bundle, changing the following file:
file: EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator// line: 309 ...$urlType = null !== $context && false === $context->getAbsoluteUrls() ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_URL;// added line: $this->urlGenerator->getContext()->setScheme('https');$url = $this->urlGenerator->generate($this->dashboardRoute, $routeParameters, $urlType);
This actually works, but is not a clean solution in my eyes.