Double Domain Name in URL for POST Request

I have created a test crud application with Flask and Python. When I try to login to the application there is a redirect that creates an invalid URL. Example below:

I am able to get to the following routes in my application without problem.

https://example.com
https://example.com/signup
https://example.com/login

However, when I am on the signup page and I click the “signup” button it should take me to the /login page but it ends up creating an invalid URL that looks like this

https://example.com,example.com/login.

What is causing this???

Here is the Nginx configuration.

server {

    server_name example.com www.example.com;
    
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/user1/example/example.sock;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP     $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {

    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name example.com www.example.com;
    return 404; # managed by Certbot

}

Do you have any Forwarding URL page rules?

The only redirect rule is when Let’s Encrypt (certbot) redirects http to https.

This topic was automatically closed after 14 days. New replies are no longer allowed.