Repository: AUTOMATIC1111/stable-diffusion-webui

Issue:
[Bug]: Gradio issue, "Value Error: File cannot be fetched: <... extensions/...the file...>"
### Is there an existing issue for this?

- [x] I have searched the existing issues and checked the recent builds/commits

### What happened?

The following error is logged:
```
ValueError: File cannot be fetched: /home/valconius/Library-Remote/C30 Documents/C3080 Stable Diffusion/Interfaces/nsd--atagen/nix-stable-diffusion--no-nixlib-in-flake/stable-diffusion-webui/extensions/stable-diffusion-webui-wd14-tagger/javascript/tagger.js. All files must contained within the Gradio python app working directory, or be a temp file created by the Gradio python app
```
However, using the extension in question, "stable diffusion webui wd14 tagger", works just fine. Not all extensions have this issue, but many do.

### Steps to reproduce the problem

1. Go to .... 
2. Press ....
3. ...


### What should have happened?

My extensions and many other files are symlinked to locations outside the webui file tree. This issue did not occur with a git pull from a couple of days ago but now occurs.

### Commit where the problem happens

216f67ec7cdec45bcfa9db40aa6bcac480e3637e

### What platforms do you use to access UI ?

Linux

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

```Shell
pytho launch.py --api
```


### Additional information, context and logs

_No response_


Discussion:
Same problem? https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6939 Scenarios are a bit different, i'll leave this one open.
Confirmed, but the ISSUE opener did focus on the wrong commit.

The REAL commit where the problem started is https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/50059ea661b63967b217e687819cf7a9081e4a0c#commitcomment-97757826

You can check it by reverting the webui to the previous commit by `git reset --hard 17af0fb95574068a1d5032ae96879dab145e173a` then the problem vanish.
Now go to the commit `git reset --hard 50059ea661b63967b217e687819cf7a9081e4a0c` and the BUG is there.


The BUG is still there as of 97ba01a2136f0482774824fc812c8faf36fd9658 (HEAD at the time of writing)

@AUTOMATIC1111 
Is there a loss of functionality or just an error message?
> ### Is there an existing issue for this?
> * [x]  I have searched the existing issues and checked the recent builds/commits
> 
> ### What happened?
> The following error is logged:
> 
> ```
> ValueError: File cannot be fetched: /home/valconius/Library-Remote/C30 Documents/C3080 Stable Diffusion/Interfaces/nsd--atagen/nix-stable-diffusion--no-nixlib-in-flake/stable-diffusion-webui/extensions/stable-diffusion-webui-wd14-tagger/javascript/tagger.js. All files must contained within the Gradio python app working directory, or be a temp file created by the Gradio python app
> ```
> 
> However, using the extension in question, "stable diffusion webui wd14 tagger", works just fine. Not all extensions have this issue, but many do.
> 
> ### Steps to reproduce the problem
> 1. Go to ....
> 2. Press ....
> 3. ...
> 
> ### What should have happened?
> My extensions and many other files are symlinked to locations outside the webui file tree. This issue did not occur with a git pull from a couple of days ago but now occurs.
> 
> ### Commit where the problem happens
> [216f67e](https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/216f67ec7cdec45bcfa9db40aa6bcac480e3637e)
> 
> ### What platforms do you use to access UI ?
> Linux
> 
> ### What browsers do you use to access the UI ?
> Mozilla Firefox
> 
> ### Command Line Arguments
> ```shell
> pytho launch.py --api
> ```
> 
> ### Additional information, context and logs
> _No response_

Sorry for the inconvenience.  Currently the documentation requires copying them into the extensions directory, but I'm checking with the author on what should be supported: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Extensions 
Try copying them directly and see if that doesn't fix the problem.
> Is there a loss of functionality or just an error message?

Yes, total loss of functionality: none of the plugins works anymore.
By the way, I'l running stable diffusion in a dockerized environment with mounted individual folders => if this is the problem, please understand it never have been one prior ths commit I referred earlier.
@martinobettucci Gradio has been making changes around the way it deals with symlinks: https://github.com/gradio-app/gradio/pull/3037 I'm keeping an eye on it.  In the meantime, in your Dockerfile, you can always mount the extensions to a separate file and then `cp -r` to the extensions directory, that should be a workaround.
I found a workaround @jjtolton, just mount the '/extension' folder as a volume in docker instead of symlinking it to you external SDD
@valconius Which version of python you are using? I have python 3.10.7 and had no issues related to gradio.
I was able to get around this via:
```bash
sed -i 's/in_app_dir = .*/in_app_dir = True/g' /usr/local/lib/python3.10/dist-packages/gradio/routes.py
```
Not sure what other implications this has.

Resolving patch:
diff --git a/modules/cmd_args.py b/modules/cmd_args.py
--- a/modules/cmd_args.py
+++ b/modules/cmd_args.py
@@ -102,3 +102,4 @@
 parser.add_argument("--skip-version-check", action='store_true', help="Do not check versions of torch and xformers")
 parser.add_argument("--no-hashing", action='store_true', help="disable sha256 hashing of checkpoints to help loading performance", default=False)
 parser.add_argument("--no-download-sd-model", action='store_true', help="don't download SD1.5 model even if no model is found in --ckpt-dir", default=False)
+parser.add_argument('--subpath', type=str, help='customize the subpath for gradio, use with reverse proxy')
\ No newline at end of file
diff --git a/webui.py b/webui.py
--- a/webui.py
+++ b/webui.py
@@ -350,6 +350,11 @@ def webui():
 
         print(f"Startup time: {startup_timer.summary()}.")
 
+        if cmd_opts.subpath:
+            redirector = FastAPI()
+            redirector.get("/")
+            mounted_app = gradio.mount_gradio_app(redirector, shared.demo, path=f"/{cmd_opts.subpath}")
+
         wait_on_server(shared.demo)
         print('Restarting UI...')
 


Test patch: