title: Firebase hosting SEO for SPA's
body: <p>For single page apps, some advanced rewrite rules need to be implemented in your server conf to proxy web crawlers and social media bots to cached pre-rendered versions of the JavaScript SPA content.</p>
  
  <p>Using a service like <a href="http://prerender.io" rel="noreferrer">http://prerender.io</a></p>
  
  <p>You will notice the various server configuration rules templated here that demonstrate this proxy:
  <a href="https://prerender.io/getting-started#install-it" rel="noreferrer">https://prerender.io/getting-started#install-it</a></p>
  
  <p>Using the <a href="https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html" rel="noreferrer">https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html</a> does Firebase support this level of sophistication?</p>
  
  <p>For example - how would I implement <a href="https://gist.github.com/thoop/8165802" rel="noreferrer">this nginx config</a> using Firebase rewrite-rules:</p>
  
  <pre><code>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;
          }
      }
  }
  </code></pre>
  
  <p>As a side note - I think it's great that you guys have support now for doing things like:</p>
  
  <pre><code>"rewrites": [ {
    "source": "**",
    "destination": "/index.html"
  }]
  </code></pre>
  
  <p>But find this really only solving half the battle that SPA's face.</p>