Home > front end >  Flask redirecting leads to time-out error
Flask redirecting leads to time-out error

Time:05-07

I have this simple redirect from '/' to '/home', handled by flask with

app.py

@app.route('/') #Redirects to home page
def redirect_home():
    return redirect("/home")

When I use it with my browser it always leads a connection timeout error, althoug when using cURL on my vps (with -L) it does lead to the webpage correctly

I believe it has to do with my nginx setup: sites-available

location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }

I used to face this issue before on my old vps and I remember fixing it by adding something to the nginx configuration but I don't remember what it was

CodePudding user response:

Try

@app.route('/', methods=['GET']) #Redirects to home page
def redirect_home():
    return redirect("/home"), 301

Add the request error if not solved..

CodePudding user response:

The issue was solved by simply allowing HTTP traffic through nginx using the command:enter code here

ufw allow 'Nginx HTTP'

I am confused by how thats what fixed it but it really did work after that Although im not sure why it only afftected redirecting

  • Related