Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirection lambda function regex missing .map, .json and whatsapp #14

Open
YuriScarbaci opened this issue Oct 31, 2019 · 3 comments
Open

Comments

@YuriScarbaci
Copy link

YuriScarbaci commented Oct 31, 2019

The lambda testing wheter to set the header for prerender.io or not isn't currently testing:

  1. user-agent for whatsapp crawler ( should be something like WhatsApp/2.19.81 A )
  2. .json files
  3. .map files
@YuriScarbaci
Copy link
Author

YuriScarbaci commented Oct 31, 2019

this can be fixed by modifying the lambda function for SetPrerenderHeader

this is the part that needs to be changed:

    if (user_agent && host) {
      var prerender = /googlebot|adsbot\-google|Feedfetcher\-Google|bingbot|yandex|baiduspider|Facebot|facebookexternalhit|twitterbot|WhatsApp|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator/i.test(user_agent[0].value);
      prerender = prerender || /_escaped_fragment_/.test(request.querystring);
      prerender = prerender && ! /\.(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|ttf|woff|svg|eot|map|json)$/i.test(request.uri);
      if (prerender) {
        headers['x-prerender-token'] = [{ key: 'X-Prerender-Token', value: '${PrerenderToken}'}];
        headers['x-prerender-host'] = [{ key: 'X-Prerender-Host', value: host[0].value}];
        headers['x-prerender-cachebuster'] = [{ key: 'X-Prerender-Cachebuster', value: Date.now().toString()}];
      }
    }

so basically adding |WhatsApp in the first regex

and

|map|json to the third regex

@jinty
Copy link
Owner

jinty commented Oct 31, 2019 via email

@YuriScarbaci
Copy link
Author

YuriScarbaci commented Oct 31, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants