Merge branch 'release' into staging

612fda4cfc1e09fa94a3fb2d7496594e9d0141db

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

1 files changed, +10 -5Ignore whitespace
src/endpoints/stable-diffusion.js+10 -5
@@ -106,8 +106,10 @@ router.post('/upscalers', jsonParser, async (request, response) => {
106106
107router.post('/vaes', jsonParser, async (request, response) => {107router.post('/vaes', jsonParser, async (request, response) => {
108 try {108 try {
109 const autoUrl = urlJoin(request.body.url, '/sdapi/v1/sd-vae');109 const autoUrl = new URL(request.body.url);
110 const forgeUrl = urlJoin(request.body.url, '/sdapi/v1/sd-modules');110 autoUrl.pathname = '/sdapi/v1/sd-vae';
111 const forgeUrl = new URL(request.body.url);
112 forgeUrl.pathname = '/sdapi/v1/sd-modules';
111113
112 const requestInit = {114 const requestInit = {
113 method: 'GET',115 method: 'GET',
@@ -295,7 +297,8 @@ router.post('/set-model', jsonParser, async (request, response) => {
295router.post('/generate', jsonParser, async (request, response) => {297router.post('/generate', jsonParser, async (request, response) => {
296 try {298 try {
297 try {299 try {
298 const optionsUrl = urlJoin(request.body.url, '/sdapi/v1/options');300 const optionsUrl = new URL(request.body.url);
301 optionsUrl.pathname = '/sdapi/v1/options';
299 const optionsResult = await fetch(optionsUrl, { headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });302 const optionsResult = await fetch(optionsUrl, { headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });
300 if (optionsResult.ok) {303 if (optionsResult.ok) {
301 const optionsData = /** @type {any} */ (await optionsResult.json());304 const optionsData = /** @type {any} */ (await optionsResult.json());
@@ -313,14 +316,16 @@ router.post('/generate', jsonParser, async (request, response) => {
313 request.socket.removeAllListeners('close');316 request.socket.removeAllListeners('close');
314 request.socket.on('close', function () {317 request.socket.on('close', function () {
315 if (!response.writableEnded) {318 if (!response.writableEnded) {
316 const interruptUrl = urlJoin(request.body.url, '/sdapi/v1/interrupt');319 const interruptUrl = new URL(request.body.url);
320 interruptUrl.pathname = '/sdapi/v1/interrupt';
317 fetch(interruptUrl, { method: 'POST', headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });321 fetch(interruptUrl, { method: 'POST', headers: { 'Authorization': getBasicAuthHeader(request.body.auth) } });
318 }322 }
319 controller.abort();323 controller.abort();
320 });324 });
321325
322 console.log('SD WebUI request:', request.body);326 console.log('SD WebUI request:', request.body);
323 const txt2imgUrl = urlJoin(request.body.url, '/sdapi/v1/txt2img');327 const txt2imgUrl = new URL(request.body.url);
328 txt2imgUrl.pathname = '/sdapi/v1/txt2img';
324 const result = await fetch(txt2imgUrl, {329 const result = await fetch(txt2imgUrl, {
325 method: 'POST',330 method: 'POST',
326 body: JSON.stringify(request.body),331 body: JSON.stringify(request.body),