Open mathieu-gilloots opened 5 years ago
Hi @mathieu-gilloots, thanks for posting a problem. Did you generate the routing.js from the command line interface? In that case you might run into the problem described in our documentation: https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/commands.html. It is needed to configure the request context as described in https://symfony.com/doc/current/console/request_context.html#configuring-the-request-context-globally. Hopefully that resolves your issue.
Hello @tobias-93
Thanks for the quick reply.
I use the <script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
method to generate my route using the controller. (but inside the controller the router has the wrong host, and wrong scheme).
For info, I try to generate route in absolute mode (to pass it to a webservice).
Any ideas of why the router in FosJSRouting is different of My "classic" Controller ones ?
Edit : more info : I'm behind a Cloudfront proxy, with :
$cloudFrontRequest = $request->headers->get('CloudFront-Forwarded-Proto');
Request::setTrustedProxies(
['127.0.0.1', $request->server->get('REMOTE_ADDR')],
Request::HEADER_X_FORWARDED_AWS_ELB
);
if(!empty($cloudFrontRequest)) {
Request::setTrustedHeaderName(Request::HEADER_X_FORWARDED_PROTO, 'CloudFront-Forwarded-Proto');
}
It's seams router from my controller understand that, but not the router in FosJSRouting controller
Thanks
Hello, I got a little problem using FosJsRoutingBundle.
When i call the router inside a Controller (let's says DashboardController) :
$this->get('router')->getContext()->getHost()
=> staging.domain.com, that's okWhen I look into 'routing.js' host are : ec2-XX-XX-XXX-XXX.eu-west-3.compute.amazonaws.com
When I look into the code behind routing.js I see it's take router in service argument. (only différence I see between my call with get() and the Controller behind routing.js).
Any ideas ?
Many thanks for your help.