The problem
I have a web-server that generates an index page that runs Angular, which uses API calls to display data.
I have meta tags which are being set by Angular API calls too.
Now if I will post my website on Facebook, the tags will not be initialized because Facebook scrawler does not support Javascript.
Solution Detect Facebook user-agent server-sided, and dedicate specific routes that will use a controller action that returns an index page already initialized with that meta data that facebook needs, using the API calls server sided.
I have tried using the condition
option that I read here in Symfony router but I am getting the following error:
Resources/config/routing.yml"
contains unsupported keys for "bot_facebook_post": "condition"
And that's how my route looks in yml:
bot_facebook_post:
pattern: /locations/{location}
condition: "request.headers.get('User-Agent') matches 'facebookexternalhit/1.1'"
defaults: {
_controller: Main:bot, slug: ""
}