gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.72k stars 2.29k forks source link

gradio webcomponent src URL path after domain ignored #7902

Open joachimt-git opened 3 months ago

joachimt-git commented 3 months ago

Describe the bug

I want to share my gradio app using a webcomponent like this.

<gradio-app src="http://www.mysite.de/gradio-demo/"></gradio-app>

I would expect that I can entirely move my app unter the path /gradio-app/ as src is described as an URL.

But that does not work. The javascript app wants to load a config and it does ignore the path /gradio-demo. From the index.js I see (line 326, version 3.46.0)

      try {
        config = await resolve_config(
          fetch_implementation,
          `${http_protocol}//${host}`,
          hf_token
        );

Only the ${host} is taken.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr

Screenshot

No response

Logs

Failed to load resource: the server responded with a status of 404 (Not Found)
index.js:362 Error: Could not get config.
    at Ar (index.js:958:11)
    at async index.js:357:52
(anonymous) @ index.js:362
/config:1 

       Failed to load resource: the server responded with a status of 404 (Not Found)
index.js:362 Error: Could not get config.
    at Ar (index.js:958:11)
    at async index.js:357:52
(anonymous) @ index.js:362
/favicon.ico:1 

       Failed to load resource: the server responded with a status of 404 (Not Found)

System Info

Chrome Browser, nginx webserver

Severity

I can work around it

freddyaboulton commented 3 months ago

I believe this has been fixed in newer versions of gradio. Can you try with the latest gradio version?

joachimt-git commented 3 months ago

I have tried version 4.24.0. Unfortunately the 404 Error for /config still is present. The line of code where /config is being searched stays the same. In 4.24.0 now the line 471 in index.js.

      try {
        config = await resolve_config(
          fetch_implementation,
          `${http_protocol}//${host}`,
          hf_token
        );
        const _config = await config_success(config);
        res(_config);
      } catch (e) {
        console.error(e);
        if (space_id) {
          check_space_status(
            space_id,
            RE_SPACE_NAME.test(space_id) ? "space_name" : "subdomain",
            handle_space_sucess
          );

I see in the js console that the exception e is thrown and caught.

Best regards

Joachim