rwanoux / stable-images

MIT License
0 stars 3 forks source link

Settings won't open #1

Open Casuallynoted opened 1 year ago

Casuallynoted commented 1 year ago

When I click the "Stable images settings" button, nothing happens. I'm running in a world without any other modules enabled.

The error I'm seeing in the console is:

foundry.js:753 TypeError: An error occurred while rendering StableImageSettings 34. Cannot read properties of undefined (reading 'sd_model_checkpoint') at StableImageSettings.getData (StableImageSettings.js:43:53) at StableImageSettings._render (foundry.js:5736:29) at StableImageSettings._render (foundry.js:6456:17) at StableImageSettings.render (foundry.js:5693:10) at SettingsConfig._onClickSubmenu (foundry.js:82888:16) at HTMLButtonElement.dispatch (jquery.min.js:2:43184) at y.handle (jquery.min.js:2:41168)

rwanoux commented 1 year ago

have you launched stable diffusion A1111 locally with the options --listen --api --cors-allow-origins="[your_local_ip_of_foundry]" ? is this the only error in the console ?

derSebastian commented 1 year ago

Same. I noticed a few things, but lets start with how I started:

Errors in Foundry: (The error @Casuallynoted lists above also appear when clicking the button in settings, but AFTER the ones below.) I have tried to issue a broad CORS inclusion with the list of various version of 'localhost' and each separate, but the result is exactly the same. Seems to fail on this way, The big thing I see is the protocol change: HTTP to HTTPS.... ?


Access to fetch at 'http://localhost:7860/sdapi/v1/loras' from origin 'https://localhost:52223' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. sdAPIClient.js:98 GET http://localhost:7860/sdapi/v1/loras net::ERR_FAILED 200 (OK) getLoras @ sdAPIClient.js:98 await in getLoras (async) getStableDiffusionSettings @ sdAPIClient.js:71 (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 sdAPIClient.js:105 Erreur lors de la tentative d'accès au loras de stable diffusion : TypeError: Failed to fetch at SdAPIClient.getLoras (sdAPIClient.js:98:36) at async SdAPIClient.getStableDiffusionSettings (sdAPIClient.js:71:9) getLoras @ sdAPIClient.js:105 await in getLoras (async) getStableDiffusionSettings @ sdAPIClient.js:71 (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 foundry.js:68147 Erreur lors de la tentative d'accès au loras de stable diffusion ; erreur = TypeError: Failed to fetch fetch @ foundry.js:68147 notify @ foundry.js:68044 error @ foundry.js:68081 getLoras @ sdAPIClient.js:106 await in getLoras (async) getStableDiffusionSettings @ sdAPIClient.js:71 (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 worker.js:73 Worker Compressor | Initialized Worker game:1 Access to fetch at 'http://localhost:7860/' from origin 'https://localhost:52223' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. sdAPIClient.js:52 HEAD http://localhost:7860/ net::ERR_FAILED 200 (OK) initConnexion @ sdAPIClient.js:52 await in initConnexion (async) (anonymous) @ module.js:55

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 sdAPIClient.js:62 Error occurred while trying to access the remote server for stable broadcasting : TypeError: Failed to fetch at SdAPIClient.initConnexion (sdAPIClient.js:52:36) initConnexion @ sdAPIClient.js:62 await in initConnexion (async) (anonymous) @ module.js:55

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 foundry.js:68147 Error occurred while trying to access the remote server for stable broadcasting; error = TypeError: Failed to fetch fetch @ foundry.js:68147 notify @ foundry.js:68044 error @ foundry.js:68081 initConnexion @ sdAPIClient.js:63 await in initConnexion (async) (anonymous) @ module.js:55

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 game:1 Access to fetch at 'http://localhost:7860/sdapi/v1/sd-models' from origin 'https://localhost:52223' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. sdAPIClient.js:134 GET http://localhost:7860/sdapi/v1/sd-models net::ERR_FAILED 200 (OK) getModels @ sdAPIClient.js:134 await in getModels (async) getStableDiffusionSettings @ sdAPIClient.js:72 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 sdAPIClient.js:141 Erreur lors de la tentative d'accès au loras de stable diffusion : TypeError: Failed to fetch at SdAPIClient.getModels (sdAPIClient.js:134:36) at async SdAPIClient.getStableDiffusionSettings (sdAPIClient.js:72:9) getModels @ sdAPIClient.js:141 await in getModels (async) getStableDiffusionSettings @ sdAPIClient.js:72 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 foundry.js:68147 Erreur lors de la tentative d'accès au loras de stable diffusion ; erreur = TypeError: Failed to fetch fetch @ foundry.js:68147 notify @ foundry.js:68044 error @ foundry.js:68081 getModels @ sdAPIClient.js:142 await in getModels (async) getStableDiffusionSettings @ sdAPIClient.js:72 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 pack-cache.ts:25 Loading documents for pack foundry-ironsworn.starforgedoracles game:1 Access to fetch at 'http://localhost:7860/sdapi/v1/prompt-styles' from origin 'https://localhost:52223' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. sdAPIClient.js:114 GET http://localhost:7860/sdapi/v1/prompt-styles net::ERR_FAILED 200 (OK) getStyles @ sdAPIClient.js:114 await in getStyles (async) getStableDiffusionSettings @ sdAPIClient.js:73 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 sdAPIClient.js:121 Erreur lors de la tentative d'accès au loras de stable diffusion : TypeError: Failed to fetch at SdAPIClient.getStyles (sdAPIClient.js:114:36) at async SdAPIClient.getStableDiffusionSettings (sdAPIClient.js:73:9) getStyles @ sdAPIClient.js:121 await in getStyles (async) getStableDiffusionSettings @ sdAPIClient.js:73 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 game:1 Access to fetch at 'http://localhost:7860/sdapi/v1/options' from origin 'https://localhost:52223' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. sdAPIClient.js:154 GET http://localhost:7860/sdapi/v1/options net::ERR_FAILED 200 (OK) getSdOptions @ sdAPIClient.js:154 await in getSdOptions (async) getStableDiffusionSettings @ sdAPIClient.js:74 await in getStableDiffusionSettings (async) (anonymous) @ module.js:51

call @ foundry.js:730

callAll @ foundry.js:687 setupGame @ foundry.js:8670 await in setupGame (async) _initializeGameView @ foundry.js:9912 _initializeView @ foundry.js:9888 initialize @ foundry.js:8574 await in initialize (async) window.addEventListener.once @ foundry.js:91640 sdAPIClient.js:161 Erreur lors de la tentative d'accès au options de stable diffusion : TypeError: Failed to fetch at SdAPIClient.getSdOptions (sdAPIClient.js:154:36) at async SdAPIClient.getStableDiffusionSettings (sdAPIClient.js:74:9)

derSebastian commented 1 year ago

Update: I fixed the CORS errors, by disabling CORS in the request call!

I changed the header from: const response = await fetch(optionsUrl, { method: 'GET' }); to: const response = await fetch(optionsUrl, { method: 'GET', mode: 'no-cors' });

Same goes for the single POST request.

But I get another error that the stable diffusion server is not accessible. from the initConnexion function. Is the default IP hardcoded?

Maybe it would be prudent to have the settings panel launch regardless of connection and initiate the connection only after a button press?

derSebastian commented 1 year ago

Fiddled with it a bit more and I can get it to fetch the 'relevant' data but the initConnexion is returning false.

When logging the get request of that function in the console I see an error in the .get f() argument: Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter (:3:28)]

Something there?

derSebastian commented 1 year ago

OK a bit more that I tried and wanted to report back: removing my certs and launching Foundry in http, I still get CORS header problems (unless I add a no-cors header), but I have read that in ECMA script the "use strict" prevents ingesting of data due to the no-cors header (I can't test this and unable to verify).

When launching in http mode and using the startup as detailed I still get the error: The remote server for stable diffusion is not accessible : response code 0 I referenced above.

I have not yet been able to launch A1111 in ssl mode to test it the other way around, but I would figure this might be similar.

rwanoux commented 1 year ago

I think you should retry without your changes but with these options: --listen --api --cors-allow-origins="https://localhost:5223" please notice the strict way the --cors-allow-origins option is filled, with the port

rwanoux commented 1 year ago

@derSebastian : have been able to make this module communicate with stable diffusion ? I am about to close this issue since it seems that the solution i pointed at to you works well in my opinion

zdaar commented 9 months ago

Hi, I had the same Issue and I couldnt get it working until I formatted the cors url like you said, "http://127.0.0.1:30000"

I had tried 127.0.0.1 127.0.0.1:30000 http://127.0.0.1 http://127.0.0.1:30000

none of those worked, had to put the full http, ip, port and quotes

You should update readme :)

Merci ;)