Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1486

Use HTTPS as Schema for all routes (Symfony 7 & EasyAdmin Bundle)

$
0
0

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.html

  • Tried 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.


Viewing all articles
Browse latest Browse all 1486

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>