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

Deployed Version redirects to localhost for authentication #538

Open
usmanarham opened this issue Apr 28, 2024 · 4 comments
Open

Deployed Version redirects to localhost for authentication #538

usmanarham opened this issue Apr 28, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@usmanarham
Copy link

usmanarham commented Apr 28, 2024

Describe the bug
i am following the custom MyAuthProvider for authentication and it works on localhost
but when i deploy it on server and hit {server_url}/admin it shows https://{server_url}/admin/login?next=http%3A%2F%2F127.0.0.1%3A8000%2Fadmin%2F

which means its redirecting to localhost

here is my setup

def init_admin(app: FastAPI) -> None:
    engine = create_async_engine(get_db_url())
    admin = Admin(
        engine,
        title="Admin",
        base_url="/admin",
        statics_dir="static",
        login_logo_url="statics/dark-logo.svg",  # base_url + '/statics/' + path_to_the_file
        auth_provider=MyAuthProvider(allow_routes=["/statics/dark-logo.svg"]),
        middlewares=[
            Middleware(
                SessionMiddleware, secret_key=SECRET
            )
        ],
    )

the login form that shows up is posting on http://127.0.0.1:8000/admin/login instead of the server url, i am thinking there is some kind of setting for this issue can anyone guide me

Environment (please complete the following information):

  • Starlette-Admin version: 0.13.2
  • ORM/ODMs: SQLAlchemy

Additional context
Add any other context about the problem here.

@usmanarham usmanarham added the bug Something isn't working label Apr 28, 2024
@usmanarham
Copy link
Author

issue was with my nginx config solved that but now having issues of serving mixed content block

@hasansezertasan
Copy link
Contributor

issue was with my nginx config solved that but now having issues of serving mixed content block

What do you mean by "mixed content block"?

@jowilf
Copy link
Owner

jowilf commented Apr 29, 2024

This looks like #424

@usmanarham
Copy link
Author

usmanarham commented Apr 29, 2024

nginx config redirects every http call to https

`server {
listen 80;
listen [::]:80;

server_name domain.com;

# Redirect all HTTP traffic to HTTPS
if ($http_x_forwarded_proto != "https") {
    return 301 https://$host$request_uri;
}

location / {
    # Proxy pass to your application
    proxy_pass http://127.0.0.1:8000/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection upgrade;
    proxy_set_header Accept-Encoding gzip;
}

autoindex_localtime on;

}`

admin index page loads with all the static file but when it make call to listing api's using jquery it makes on http and gets blocked by browser

Access to XMLHttpRequest at '**http://**domain.com/admin/api/consumer?skip=0&limit=10&order_by=id%20asc' from origin '**https:**//domain.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants