Reputation: 1
I'm trying to run Dash app using Flask on my server with Kubernates
import dash
import dash_html_components as html
from flask import Flask
server = Flask(__name__)
app = dash.Dash(name='my-server', server=server)
app.layout = html.Div([
....
])
@server.route("/")
def dash_app():
return app.index()
if __name__ == '__main__':
server.run(host='0.0.0.0')
Obviously have more stuff(like more html and callback functions).
When create a docker image and run it locally, it runs perfectly fine at 127.0.0.1:5000
, though when I push it to my server and run it with kubernates, it gives me the following errors.
Refused to execute script from '<URL>' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
And
Uncaught ReferenceError: DashRenderer is not defined
And stuck with "Loading..." screen.
Any help/insight would be appreciated! Thanks :)))
Upvotes: 0
Views: 1695
Reputation: 786
I had same issue and in my situation the solution was to just set the requests_pathname_prefix
like this:
app = Dash(requests_pathname_prefix="/your_prefix/")
Setting the environment variable or both requests_pathname_prefix
and routes_pathname_prefix
lead to the site being unavailable.
Upvotes: 1
Reputation: 11
hihi, i have experienced this issue also. After debugging, it was due to browser cannot get those javascript files. Thus, need to let it know where to find them.
Suppose you want to deploy to your k8s at
<domain-name>/mycooldashboards/dashboard-1
. You can add an env var to the dash deployment as below
name: DASH_URL_BASE_PATHNAME
value: /mycooldashboards/dashboard-1/ # needs to end by slash
Also, your ingress need to support users to get/post. The path in ingress is like:
/mycooldashboards/dashboard-1(/|$)(.*)
Then it should work for you.
here is the source of information: https://dash.plotly.com/reference (just look for DASH_URL_BASE_PATHNAME)
Upvotes: 0