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

Not getting rendered HTML; getting only SPA #14

Open
zry754331875 opened this issue Jan 21, 2019 · 21 comments
Open

Not getting rendered HTML; getting only SPA #14

zry754331875 opened this issue Jan 21, 2019 · 21 comments

Comments

@zry754331875
Copy link

When l choose display web page source code,it still spa.
image
image

@zry754331875
Copy link
Author

l used create-react-app's webpack-dev-server,port is 3000

@ghost
Copy link

ghost commented Jan 23, 2019

Hello,
this tool is a great Idea, but I won't get it work too.

I started the Docker version of Headless Chrome exactly as in your docs and I started the rendora container like this:

docker run --net=host -v ${PWD}/config.yaml:/etc/rendora/config.yaml rendora/rendora
Configuration loaded
Connected to headless Chrome
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

This is my config.yaml:

listen: 
    address: 0.0.0.0
    port: 3001
target:
    url: "http://127.0.0.1:80"
backend:
    url: "http://127.0.0.1:80"
headless:
    waitAfterDOMLoad: 1000
    internal:
        url: http://localhost:9222
    timeout: 5
output:
    minify: true
debug: true
cache:
    type: none
filters:
    userAgent:
        defaultPolicy: whitelist

I'm running an angular SPA from ./dist/ folder, served by a little Golang fileserver on port 80.
When I type "http://127.0.0.1/" in my browser, I get my SPA when I type "http://127.0.0.1:3001" I get nothing (ERR_CONNECTION_REFUSED). I can't get any connection to rendora.

Any idea, what I'm doing wrong?

Is it possible to print out, where the rendora serve is listening and from which location it's fetching content? I can't really understand what is backend, target and listen.

Thanx :)

@zry754331875
Copy link
Author

@LooneyDude You should type "http://0.0.0.0:3001"

@ghost
Copy link

ghost commented Jan 24, 2019

@zry754331875 Unfortunately that does not work either.

@xiaoxiaotestnote
Copy link

@rrjanbiah
Copy link

rrjanbiah commented Mar 16, 2019

Perhaps the title should be reworded to Not getting rendered HTML; getting only SPA

I too have the same problem that not getting rendered outerHTML... but getting only the SPA HTML. So, it works in browser, but not for bots.

Increasing waitAfterDOMLoad to 5000 doesn't even help. Looks like the code to fetch outerHTML should be modified to use use --dump-dom flag of chrome.

Apologies @wpajqz @makemesteaks @MiguelFreire for tagging... but as you people seem to have active fork, do you have any insights to share? TIA

Edit: It is --dump-dom, not --dump-html as I noted earlier. CLI that works: chromium-browser --headless --disable-gpu --dump-dom {url}

@zry754331875 zry754331875 changed the title It dosen't work Not getting rendered HTML; getting only SPA Mar 16, 2019
@rrjanbiah
Copy link

Some notes as I search about this issue... (so that in case, if it helps anyone to come up with some solution or so)

I searched for --dump-dom in CDP, the library created by @mafredri (which is used by Rendora) and found https://github.com/mafredri/cdp/issues/55 So, based on initial understanding, this doesn't seem to be possible. So, wondering how others are using for SSR and SEO.

@rrjanbiah
Copy link

@zry754331875
Copy link
Author

@rrjanbiah Thank you for your help.I will try it again

@rrjanbiah
Copy link

@zry754331875 I'm also facing same issue.. not yet resolved for me... I'm just searching for solutions. If you find any please do share

@zry754331875
Copy link
Author

@rrjanbiah Did the above article have no effect? If I find a solution I will share it here.

@rrjanbiah
Copy link

@zry754331875 Article only says that it will return rendered HTML.. which is not the case for me. I still have no luck. Thank you

@rrjanbiah
Copy link

Some more observation

curl --header "Content-Type: application/json" --data '{"uri": "/"}' -X POST 127.0.0.1:9242/render returns rendered HTML :-) (will need to enable server) But, still no luck with default Rendora as reverse proxy.

@rrjanbiah
Copy link

Finally, got it working!

curl --header "Content-Type: application/json" -X GET 127.0.0.1:9242/metrics really helped me to track the issue.

I was getting rendora_requests_total 5 and rendora_requests_ssr 0. So, as per README, rendora_requests_ssr means whitelisted requests. So, something is wrong... I added below lines to whitelist all useragents:

filters:
    userAgent:
        defaultPolicy: whitelist

That fixed the issue. Not sure if whitelisting all is the right approach.. but it works for now. Thanks for the nice library!

@zry754331875 Hope this will work for you too!

@rrjanbiah
Copy link

@zry754331875 Are you able to get it working?

@zry754331875
Copy link
Author

@rrjanbiah Sorry, I don't have time to try again. I will try your way when I have time.

@rrjanbiah
Copy link

@zry754331875 Sure

@heat
Copy link

heat commented Sep 2, 2019

Finally, got it working!

curl --header "Content-Type: application/json" -X GET 127.0.0.1:9242/metrics really helped me to track the issue.

I was getting rendora_requests_total 5 and rendora_requests_ssr 0. So, as per README, rendora_requests_ssr means whitelisted requests. So, something is wrong... I added below lines to whitelist all useragents:

filters:
    userAgent:
        defaultPolicy: whitelist

That fixed the issue. Not sure if whitelisting all is the right approach.. but it works for now. Thanks for the nice library!

@zry754331875 Hope this will work for you too!

It`s work like a charm.
The ssr was only fire to bots, when sets user agent to whitelist, whatever browsers hit the ssr.

@rrjanbiah
Copy link

@heat Glad to know it worked for you too.

@AlexanderTserkovniy
Copy link

Have the same issue, what am I doing wrong?

Config:

debug: true
listen:
    port: 3031

cache:
    type: none
    timeout: 60
    redis:
        address: localhost:6379

target:
    url: "http://127.0.0.1"

backend:
    url: "http://react-compare-app.surge.sh"

headless:
    waitAfterDOMLoad: 5000
    internal:
        url: "http://127.0.0.1:9222"

output:
    minify: true

server:
    enable: true

Doing curl returns the same as View Page Source.

@rrjanbiah
Copy link

@AlexanderTserkovniy Please check my note above on whitelisting useragents #14 (comment) That should work.

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

5 participants