jeroennoten / Laravel-Prerender

Laravel middleware for prerendering javascript-rendered pages on the fly for SEO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only get empty HTML page

stiegenaufgang opened this issue · comments

I have a working prerender.io server on http://localhost:3000 and I want to use this server for my Laravel project to prerender my ember code. I installed the plugin and changed the server URL in the config file. I also added the googlebot to the crawler_user_agents array, but every time I request the website with the googlebot user agent, I only get the following response:

<html><head></head><body></body></html>

I also tried the following URLs, with and without the googlebot user agent and with and without the googlebot in the crawler_user_agents array, but the result is the same.

  • http://localhost:8000/products?_escaped_fragment_
  • http://localhost:8000/?_escaped_fragment_
  • http://localhost:8000/?_escaped_fragment_=/products
  • http://localhost:8000/products/?_escaped_fragment_=

The strange thing is that my running prerender.io server is logging the Laravel requests correctly and I get the correct result when I request this URL http://localhost:3000/http://localhost:8000. I am currently using Laravel 4.2.
I hope you could help me with my problem.

Thanks for the issue, I will take a look into it.

The default configuration disables use of the prerender on the local environment by default. Did you set enable to true in app/config/packages/nutsweb/larave-prerender/local/config.php?

Thanks for helping me with my problem. I also thought this was the problem, but setting the config value enable in the local config file to true hasn't really changed anything.

How is your local server setup? Do you run homestead at port 8000? Then it might be the case that the homestead server it cannot reach your prerender server at port 3000, because homestead is a server running as a virtual machine on your computer. To verify that this is the problem, set up a route with something like this:

Route::get(
    '/test',
    function () {
        return file_get_contents('http://localhost:3000/http://localhost:8000');
    }
);

And then go to http://localhost:8000/test. What do you get?

I tested the code and I got the same empty HTML page on http://localhost:8000/test.
I don't use Homestead, but for local development I use php artisan serve with MAMP.

Hmm.. it should not be a problem with artisan serve... So if I understand you correctly: if you try http://localhost:3000/http://localhost:8000 in the browser, it works correctly, but if PHP tries http://localhost:3000/http://localhost:8000, it does not work correctly? I'm doubting whether your request does hit the right test route in Laravel.

What if you change that test code above to the following and visit http://localhost:8000/test?

Route::get(
    '/test',
    function () {
        echo 'Test:<br>';
        dd(file_get_contents('http://localhost:3000/http://localhost:8000'));
    }
);

Do you still get an empty HTML page? Or first Test: and then the HTML code below it?

That's correct. If I use your code I get the following response:

Test:<br>string(39) "<html><head></head><body></body></html>"

What if you replace localhost by 127.0.0.1?

On Tue, Nov 25, 2014 at 12:54 PM, stiegenaufgang notifications@github.com
wrote:

That's correct. If I use your code I get the following response:

Test:<br>string(39) "<html><head></head><body></body></html>"

Reply to this email directly or view it on GitHub:
#3 (comment)

I got the same result.
I reinstalled my local webserver and it's working now.
Thanks for your fast support, I really appreciate your help.

Ok good, no problem.