Coder Social home page Coder Social logo

Comments (3)

IBestuzhev avatar IBestuzhev commented on September 25, 2024

I encountered a very similar issue: we use FastAPI.root_path parameter because app is running behind a proxy.

I think the most correct way is to rely on FastAPI resolver - call fastapi.Request.url_for.

Meanwhile, I did a quick workaround in my project:

        admin = Admin(
            app,
            engine,
            authentication_backend=auth_backend,
            base_url='/admin-ui',
        )
        admin.add_view(view)
        if view.is_model and app.root_path:
            # This URL goes directly into template into Select2 widget
            # With current code (sqladmin 0.16.1) it goes as is
            # The URL will be: /admin-ui/my-model/ajax/lookup
            # But the correct one for production is prefixed
            # /proxy-prefix/admin-ui/my-model/ajax/lookup
            view.ajax_lookup_url = app.root_path + view.ajax_lookup_url

from sqladmin.

infanasotku avatar infanasotku commented on September 25, 2024

@IBestuzhev yes, it works.

from sqladmin.

aminalaee avatar aminalaee commented on September 25, 2024

@IBestuzhev But the Request.url_for is not available in this context.

from sqladmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.