FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

Scheme missing in dump #370

Closed takali closed 1 year ago

takali commented 4 years ago

When I generate a JSON file of routes (bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json), I got an issue with the scheme.

When i set a global scheme in my parameter, the scheme is not in my json file

# config/services.yaml
parameters:
    router.request_context.scheme: 'https'
    asset.request_context.secure: true

When i force the scheme in the annotations file, for all controlles (or one specific controller) the scheme is not in my json file

# config/routes/annotations.yaml
controllers:
    resource: '../src/Controller/'
    type: annotation
    defaults:
        schemes: [https]

If i specify the scheme in the Route annotation @Route("/login", name="login", schemes={"https"}), it does works and the scheme is in my json file.

The thing is i do not want to specify scheme route by route, i'd rather do it globally (in parameters.yaml or annotations.yaml) becauce it allow me to set different scheme by env (http in local, https in production...). Is there a way to set a global scheme in my dump json ? My FOSJSRouting version is 2.4.0 Symfony version : 4.3

tobias-93 commented 4 years ago

Hi @takali,

I'm sorry you're experiencing problems, and that it took me a while to answer you. In our projects, we do it in a similar way to yours, so I'm not sure what's going on in your situation. We don't define the defaults in the annotation.yaml, that is already handled by the router.request_context.scheme parameter. However, we do also configure the host in the router.request_context.host parameter. Does it help when you also configure that?