Firebase hosting SEO for SPA

For single-page applications, some specific rewriting rules must be implemented on your server in order to trust proxies and social media bots for cached pre-displayed versions of JavaScript content.

Using a service like http://prerender.io

You will see here various server configuration templates that demonstrate this proxy server: https://prerender.io/getting-started#install-it

Using https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html , does Firebase support this difficulty level?

For example, how to implement this nginx configuration using Firebase rewrite rules:

server { listen 80; server_name example.com; root /path/to/your/root; index index.html; location / { try_files $uri @prerender; } location @prerender { #proxy_set_header X-Prerender-Token YOUR_TOKEN; set $prerender 0; if ($http_user_agent ~* "baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest") { set $prerender 1; } if ($args ~ "_escaped_fragment_") { set $prerender 1; } if ($http_user_agent ~ "Prerender") { set $prerender 0; } if ($uri ~ "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent)") { set $prerender 0; } if ($prerender = 1) { rewrite .* /$scheme://example.com$request_uri? break; proxy_pass http://service.prerender.io; } if ($prerender = 0) { rewrite .* /index.html break; } } } 

As a side note - I think it's great that you guys now support things like:

 "rewrites": [ { "source": "**", "destination": "/index.html" }] 

But finding it really only decides half the battle that face SPA.

+6
source share
2 answers

Firebase kernel developer is here

Firebase has announced basic SEO support that makes it work with Googlebot at ng-conf 2015 in March. See this presentation around the 16:30 mark for an announcement.

Firebase is still striving to work with pre-rendering tools like prerender.io and Brombone at some point to allow even more complex options for SEO. But this should work if you upgrade to the latest version of the Firebase client (2.2.4 at the time of publication).

+12
source

As of October 10, 2014, Firebase seems to officially say no: https://github.com/firebase/firebase-tools/issues/33

An alternative is the Divshot host. They offer a Prerender solution that is very easy to implement: http://docs.divshot.com/services/prerender

+1
source

Source: https://habr.com/ru/post/974704/


All Articles