Search code examples
python-3.xdockerdocker-composefastapistarlette

Admin page static data not visible with starlette-admin in a fastapi project with HTTPS


I am working on a FastAPI project that is secured with HTTPS, I was able to dockerize the project and add starlette-admin into the project, It works correctly in my system but when i deploy the admin page static files is not visible, I checked the network tab of the admin page, I found out that the static files used for this page are loaded via HTTP instead of HTTPS so I think that's causing the error, please share a solution for it.


Solution

  • I had a similar issue, and it managed to work with the solution at Stack Overflow Similar Issue

    In summary, you just need to add --forwarded-allow-ips=* to your command in docker compose or docker file, like this:

     version: '3.3'
    
      services:
        project_backend:
          build:
            context: .
          ports:
            - "8000:8000"
          command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--forwarded-allow-ips=*"]