prerender rendered the wrong url

I had AngularJS and Express project. AngularJS used for frontend, and expressJS used for server. Both are separated projects, and also different URL. When I install middleware in expressJS, it receive the express domain URL which is wrong.


var prerender = require('prerender-node');
prerender.set('prerenderToken', 'MY_TOKEN');

AngularJS with Nginx Conf

server {
    listen 80;
    sendfile off;
    expires 0;
    location / {
        root /usr/share/nginx/html;
        index index.html index.htm;
        try_files $uri @prerender $uri/ /index.html =404;

        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, OPTIONS';

    location @prerender {
        proxy_set_header X-Prerender-Token MY_TOKEN;

        set $prerender 0;
        if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator") {
            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|ttf|woff|svg|eot)") {
            set $prerender 0;

        #resolve using Google's DNS server to force DNS resolution and prevent caching of IPs

        if ($prerender = 1) {

            #setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing
            set $prerender "";
            rewrite .* /$scheme://$host$request_uri? break;
            proxy_pass http://$prerender;
        if ($prerender = 0) {
            rewrite .* /index.html break;


ExpressJS running at, while AngularJS run in

Prerender io receive, it should be

Source: AngularJS