How to remove leading slashes on GET requests?

I am attempting to put Dash behind some Java middleware called (shinyproxy)[https://www.shinyproxy.io/] however since the requests are being handled by the middleware there are some Dash resources that fail to load. 404s occur on

_dash-layout
_dash-dependencies

I’ve asked about this on the shinyproxy forum this was the advice I received:

that means the href being used was “/_dash-layout” and not “_dash-layout”. Do you control the hrefs? If so, removing the slash may solve your issue.

I’ve been trying to remove the leading slash.

Attempt 1

server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server, url_base_pathname='')

This breaks the app with the following error: ValueError: urls must start with a leading slash

Attempt 2
Taken from the responses on the question Deploy Dash on apache server I tried to remove prefixes

app.config.update({
    # as the proxy server will remove the prefix
    'routes_pathname_prefix': ''

    # the front-end will prefix this string to the requests
    # that are made to the proxy server
    , 'requests_pathname_prefix': ''
})

But that was probably never going to work!

Do you have any advice on removing the slashes for the requests? Or alternative solutions?

It’s working!

The solution was coded in the Dash code as follows:

# In order to work on shinyproxy
app.config.supress_callback_exceptions = True
app.config.update({
    # as the proxy server will remove the prefix
    'routes_pathname_prefix': ''

    # the front-end will prefix this string to the requests
    # that are made to the proxy server
    , 'requests_pathname_prefix': ''
})

1 Like