Upto this point everything was working fine locally. Once I added Nginx proxy, I got the below issue
Issue:
urls for _dash-layout and _dash-dependencies are missing the revers proxy uri. For example, I am serving my flask app at www.example.com/app/. But, on the browser, I saw that requests for _dash-layout and _dash-dependencies are coming at www.example.com/dashpp/_dash-layout instead of www.example.com/app/dashpp/_dash-layout.
I read the following forum discussion and tried applying the solution, and got this error, requests_pathname_prefix needs to start with ‘/’`
Anyone has pointers to what is missing. I am new to dash. So, if I missed adding any information please let me know, I will be happy to give additional details
Thanks
Edit:
To add additional context, I found out that url for _dash-component-suites is generated as expected www.example.com/dashpp/_dash-component-suites. I went through the dash source code to understand how urls are generated. Both, _dash-component-suites and _dash-layout are prefixed with routes_pathname_prefix. Line 428 to 448 of dash.py in version 1.14.0 has the code for building urls.
I believe Dash doesn’t know that you’ve configured nginx with the additional app route prefix, so you need to make it aware of that. Try initialising the Dash instance with requests_pathname_prefix='/app/dashapp/' .
Hi @ned2 , thanks for the reply. I incorporated your suggestion and added requests_pathname_prefix='/app/dashapp/' . The dash UI is stuck and displayed Loading . Upon inspecting, I got this error in console
Uncaught ReferenceError: DashRenderer is not defined
That looks like it could be describing your situation. I’d try opening up the network tab in the browser dev tools and then reload the page. If there’s any failed network requests, have a look at the URLs they’re sending to to diagnose how you might need to change the value of requests_pathname_prefix
If Dash is going to be sending sending requests to the server at /app/dashapp/, with the app prefix coming from the nginx redirect, the dashapp part of the prefix still needs to be specified by the app itself.
But it has been a while since I’ve had my head in this space, so hopefully I’m on the right track
Thanks for clarifying @nedned. I did try this config. When I gave requests_pathname_prefx=/app/dashapp/ and routes_pathname_prefix='/dashapp/', urls were being generated as www.example.com/app/app/dashpp/_dash-component-suites/
This is due to sub_filter I have in nginx config. I needed that subfilter because I have bunch of css files to render on the page.
Yes, I did try applying solutions 1 and 2. In both cases, urls for _dash-layout and _dash-dependecies were missing /app. For example, www.example.com/dashpp/_dash-layout instead of www.example.com/app/dashpp/_dash-layout