Check of optionsResult.ok

d463677328f394199263bcac836735f0defd99f2

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +6 -4Ignore whitespace
src/endpoints/stable-diffusion.js+6 -4
@@ -297,11 +297,13 @@ router.post('/generate', jsonParser, async (request, response) => {
297297 try {
298298 const optionsUrl = urlJoin(request.body.url, '/sdapi/v1/options');
299299 const optionsResult = await fetch(optionsUrl, { headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });
300- const optionsData = /** @type {any} */ (await optionsResult.json());
300+ if (optionsResult.ok) {
301- const isForge = 'forge_preset' in optionsData;
301+ const optionsData = /** @type {any} */ (await optionsResult.json());
302+ const isForge = 'forge_preset' in optionsData;
302303
303304 if (!isForge) {
304305 _.unset(request.body, 'override_settings.forge_additional_modules');
306+ }
305307 }
306308 } catch (error) {
307309 console.log('SD WebUI failed to get options:', error);