I am facing a very similar issue; this is my config:
# cat test.wsgi
import sys
#Expand Python classes path with your app's path
sys.path.insert(0, "/xyz/apache/www/html/dash/")
from app import server
application = server
[Mon Aug 28 18:01:27 2017] [error] [client 10.3.7.168] File does not exist: /xyz/apache/www/html/_dash-layout, referer: http://web/dash/
[Mon Aug 28 18:01:27 2017] [error] [client 10.3.7.168] File does not exist: /xyz/apache/www/html/_dash-dependencies, referer: http://web/dash/
The error that I see is âError loading layoutâ
Just to add my webserver is configured behind a proxy, not sure if that has something to do with this error. I also tried changing the os.environ variable in the app.py file but that also results in the same error. It would be great if someone can help with this.
Also, want to point out the below error is trying to load _dash-layout & _dash-dependencies from the primary www/html/ directory while the app is present in www/html/dash/ folder if that points to a specific problem:
[Mon Aug 28 18:01:27 2017] [error] [client 10.3.7.168] File does not exist: /xyz/apache/www/html/_dash-layout, referer: http://web/dash/
[Mon Aug 28 18:01:27 2017] [error] [client 10.3.7.168] File does not exist: /xyz/apache/www/html/_dash-dependencies, referer: http://web/dash/
My app tries to load /_dash-component-suites/dash_core_components/rc-slider@6.1.2.css?v=0.12.4.
However, the proper path is /myapp/_dash-component-suites/dash_core_components/rc-slider@6.1.2.css?v=0.12.4.
How can I adjust?
I changed url_base_pathname and app.config.requests_pathname_prefix, but it doesnât work.
Try change the dash.conf to WSGIScriptAlias / /var/www/html/wsgi/showtemperature.wsgi
You can set then the relative path of your app in dash code as: app = dash.Dash(name=âyour_app_nameâ,sharing=True, server=server.server, url_base_pathname=â/showtemperatureâ)
If the WSGI alias is set to non-root, e.g.
WSGIScriptAlias /path_to_dash_app /var/www/html/wsgi/showtemperature.wsgi
But inside dash, itâs not ware of that alias path. It will still trying to load components say dash-layout from the root path plus url_base_pathname.
Having the same problems. I tried to fix them by redirecting the requests to /_dash-layout and /_dash-dependencies to the correct path. After this the layout loads correctly but the graphs donât work since the POST to /_dash-update-component goes to the wrong path which canât be fixed with a redirect. There should be a configurable variable to set the path for the directory in the case that the Dash app isnât hosted in the root url of the server.
This should be the url_base_pathname. Additionally, I have added two additional config properties:
routes_pathname_prefix - This adds a prefix to the name of the backend routes that the server expects. This is initialized to url_base_pathname
requests_pathname_prefix - This adds a prefix to the API calls that are made by the Dash front-end to the server. This is initialized to url_base_pathname
So, if your app is served under /my-proxy/ but your proxy server removes the /my-proxy/ prefix before forwarding the request to the underlying dash server, you can set
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': '/my-proxy/'
})
However, if your proxy server does not remove this prefix before forwarding the requests, you can just set both of these variables to the same prefix.
These variables are new, so youâll need to upgrade to the latest dash and dash-renderer:
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import csv
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config.update({
#'url_base_pathname': '/showtemperature1/',
# as the proxy server will remove the prefix
'routes_pathname_prefix': '/showtemperature2/',
# the front-end will prefix this string to the requests
# that are made to the proxy server
'requests_pathname_prefix': '/pompidom3/'
})
server = app.server
print app.config
# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import csv
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config.update({
#'url_base_pathname': '/showtemperature1/',
# as the proxy server will remove the prefix
'routes_pathname_prefix': '/showtemperature2/',
# the front-end will prefix this string to the requests
# that are made to the proxy server
'requests_pathname_prefix': '/pompidom3/'
})
server = app.server
app.layout = html.Div([])
if __name__ == '__main__':
app.run_server(debug=True)
Thought Iâd update this thread since the solutions above didnât work for me. I think the config system changed to be constructor based somewhere along the way. Iâm on dash-0.40.0 now.
The below worked for me to host my dash app off a url-prefix.