Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Used with prerender spa plugin returns 400 error

See original GitHub issue

Hello, I’m using a prerendering plugin (prerender spa plugin). I got this error in console :

GET 400 ()

The network inspector returns :

Please enable JavaScript to get a reCAPTCHA challenge.

This seems not to work when prerendering. Is there any way to make it work ? Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

esmsntcommented, Jul 5, 2017

I had a similar issue with prerender-spa-plugin. I recommend you run a quick post-processing on the prerender-spa-plugin output and strip out the recaptcha script tags. Your Vue instance will re-insert them when it takes over from the pre-rendered page. Here is what I used in my prod webpack file:

Ignore the stuff about toasted-vue, that also causes a problem if it renders a toast inside the phantomjs prerender. You will need to install cheerio (npm --save install cheerio ).

    // Recommended for SEO
    // Be sure to add this
    // Otherwise PhantomJS polyfill does not get injected
    new PrerenderSpaPlugin(
      // Path to compiled app
      path.join(__dirname, '../dist'),
      // List of endpoints you wish to prerender
      [ '/', '/terms', '/privacy', '/contact' ],
        captureAfterTime: 10000,
        navigationLocked: true,
        postProcessHtml: function (context) {
          // Post Process the static rendered HTML to clean up some issues
          var $ = cheerio.load(context.html)
          // Remove cookie notification popup
          //  <div id="toasted-container" class="bottom-right"> ... </div>
          // Remove recaptcha script tags
          //  <script type="text/javascript" async="" src=""></script>
          //  <script src=";render=explicit" async="" defer="" data-vue-meta="true"></script>
          var recaptchaRegex = /recaptcha/i
          $('head').find('script').each(function (i, elem) {
            if (recaptchaRegex.test($(this).attr('src'))) {
          return $.html()

You may also find that setting navigationLocked=true seems to fix the recaptcha most of the time…

stale[bot]commented, Jan 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prerender-spa-plugin not working on the server - Stack Overflow
I'm trying to run build on the server. But with prerendering, the following error occurs. On desktop ...
Read more >
Pre-Render A Vue.js App (With Node Or Laravel)
Firstly we need to add prerender-spa-plugin to our webpack config. Make sure it comes after html-webpack-plugin .
Read more >
Pre-Render a Vue.js App (With Node Or Laravel) - DZone
We now need to use prerender-spa-plugin in our webpack config to perform the pre-rendering. Make sure it comes after html-webpack-plugin . var ...
Read more >
vue预渲染之prerender-spa-plugin解析(二) - CSDN博客
const PrerendererInstance = new Prerenderer(this._options) PrerendererInstance.initialize() .then(() => { return PrerendererInstance.
Read more >
prerender-spa-wp5-plugin - npm
Dynamic Content - If your render routes that have content that's specific to the user viewing it or other dynamic sources, you should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found