Links in Parse Server emails are broken (validate account, reset password...)

Hello everyone :blush:

I try to install a Parse server on my local server (Ubuntu 20.04).

All features works fine… except one: the email system (for reset password or validate email address for example). I installed an adapter and the emails are sent, but the link they contain is broken: when I click on it I am redirected to an “Invalid link” page. After few hours of investigation, I don’t understand what happen.

Here are my configuration files:

  • First, I use Nginx as a proxy, here is the part of my config file for my domain name which concern my Parse server:


     location ~ ^/parse/(.*)$ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://127.0.0.1:1337/parse/$1;
                proxy_ssl_session_reuse off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header Host $host;
            }
         location /parsedashboard {
                include proxy_params;
                proxy_pass http://0.0.0.0:4040;
            }
        
            location /login {
                include proxy_params;
                proxy_pass http://0.0.0.0:4040/login;
            }
        
            location /bundles {
                include proxy_params;
                proxy_pass http://0.0.0.0:4040/bundles;
            }
        
            location ~ ^/apps(.*)$ {
                include proxy_params;
                proxy_pass http://0.0.0.0:4040/apps$1;
            }

  • Here is my Parse config.js file :


    {
      "appName": "App name - Parse Server",
      "logsFolder": "/var/www/my/app/logs/",
      "databaseURI": "mongodb://localhost:27017/parsedb",
      "appId": "my_app_id",
      "masterKey": "my_master_key",
      "serverURL": "http://localhost:1337/parse",
      "publicServerURL": "https://my_domain.ovh/parse",
      "port": 1337,
      "cloud": "/var/www/my/app/cloud/main.js",
      "push": {
          "android": {
                "apiKey": "my_api_key"
          }
      },
      "liveQuery": {
        "classNames":["Class_1", "Class_2", "Class_3"]
      },
      "verifyUserEmails": true,
      "emailAdapter": {
        "module": "parse-server-mailgun-adapter-template",
        "options": {
          "fromAddress": "My app ",
          "domain": "my_domain.mailgun.org",
          "apiKey": "my-api-key"
        }
      }
     }

The links which are contained in e-mails seems good, for example:


https://my_domain.ovh/parse/apps/APP_ID/request_password_reset?token=TOKEN&username=juju

But as I said, it redirects to an “Invalid link” page.

I tried to understand why this redirection happens by adding some log in parse-server/lib/Routers/PublicAPIRouter.js, in requestResetPassword(req) method and I saw that username and token got from query are empty:



     const {
          username,
          token: rawToken
        } = req.query;
        const token = rawToken && typeof rawToken !== 'string' ? rawToken.toString() : rawToken;
    
        if (!username || !token) {
                _logger.default.info("  - usn : " + (!username) + ", token : " + (!token));
          return this.invalidLink(req);
        }

I have the log: " - usn : true, token : true"

I’m not a expert in NodeJS (euphemism :sweat_smile:) so I don’t really know how to continue my investigations.

Do you have an idea of the cause of this problem?
(For information, all others features of my Parse server work fine: database access, cloud code, live query, dashboard…)

Thank you in advance :slight_smile:

Julien

The problem is probably related to your nginx setup (and not node :slight_smile: ). Please take a look at the thread below:

1 Like

Ok thank you very much !

I will look this thread :nerd_face:

It works !

Thank you @davimacedo , indeed the problem was in nginx configuration. I just added $is_args$args at the end of the “proxy_pass” line and all works :+1:t2:

The complete line is:
proxy_pass http://127.0.0.1:1337/parse/$1$is_args$args;

1 Like