Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to open Kedro viz build folder locally? #1918

Closed
noklam opened this issue May 21, 2024 · 5 comments · Fixed by #2126
Closed

How to open Kedro viz build folder locally? #1918

noklam opened this issue May 21, 2024 · 5 comments · Fixed by #2126

Comments

@noklam
Copy link
Contributor

noklam commented May 21, 2024

Description

Is your feature request related to a problem? A clear and concise description of what the problem is: "I'm always frustrated when ..."

I have a request from user which need to share viz with 0 infrastructure. At the end I recommend just using kedro viz build and open the index.html directly. My impression is that I can open the index.html, but it doesn't work as I get a kedro-viz UI but things are not loaded properly. Maybe the it's a routing issue similar to the sub-path?
image

I recalled I can do this with sphinx doc build. At the end I have to use the vscode extension "Live Serverand openindex.html` with it, so it's a mini web server running behind.

Questions:

  • Is it possible to open it without a web server?
  • If so, what are the steps?
@dcfalcon
Copy link

Same exact issue over here

@dcfalcon
Copy link

dcfalcon commented Jun 24, 2024

After a few checks the reason we are not able to visualize it properly is the next one (using the console )
Access to fetch at 'path_project/build/api/main' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Maybe it's not the best but if you want a fast fix you can do the next.

Go to the folder build/ and run python -m http.server 8000 creating your own http server and then will work

@astrojuanlu
Copy link
Member

Previously reported at #1721 (comment)

@jitu5
Copy link
Contributor

jitu5 commented Oct 7, 2024

Currently, attempting to run kedro-viz by simply opening index.html through the file:// protocol causes CORS issues. Most modern browsers enforce strict CORS policies for local files to prevent security vulnerabilities.

The issue is inherently linked to browser-level security, not something that can be resolved purely by modifying the frontend code or server configurations. Changing browser CORS behavior from the JavaScript side or embedding special headers is not possible when using file:// due to the restrictions set by browser for security reasons.

Therefore, the recommendation for a proper user experience is to run kedro-viz using a local web server, which avoids CORS policy issues and guarantees that all resources are correctly served and accessed. Examples of lightweight static servers include Python's http.server or Node.js http-server, which can easily serve the generated HTML.

I will update existing documentation of kedro viz build to highlight right way to use build folder.

@github-project-automation github-project-automation bot moved this from In Review to Done in Kedro-Viz Oct 10, 2024
@astrojuanlu
Copy link
Member

To note, a user complained last week that lack of "double click" open was a limitation for them. So, although we've documented why this is not currently possible in #2126 👍🏼 I think we should keep an eye on this and, if we notice more people are affected, try reworking the output of kedro viz build so that it's not affected by CORS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants