CursedChrome icon indicating copy to clipboard operation
CursedChrome copied to clipboard

Redirect Url for 302 status code

Open onemetafox opened this issue 2 years ago • 0 comments

For the redirect (302 status code), the return value is not working.

If the response status code is 302, follow code will run. `const redirect_hack_id = uuidv4();

    redirect_table[redirect_hack_id] = JSON.parse(JSON.stringify({
        'url': details.url,
        'status_code': details.statusCode,
        'headers': details.responseHeaders
    }));
    return {
        redirectUrl: `${location.origin.toString()}/redirect-hack.html?id=` + redirect_hack_id
    };`

But the return value (redirectUrl) is not accepted it.

   ` try {
              var response = await fetch(
                  params.url,
                  request_options
              );
        } catch (e) {
            console.error(`Error occurred while performing fetch:`);
            console.error(e);
            return;
        }
    
        var response_headers = {};
        // var cookies = await get_cookies({"domain": '.cookiepro.com'});
        // response_headers = cookies;
        for (var pair of response.headers.entries()) {
            
            // Fix Set-Cookie from onHeadersReceived (fetch() doesn't expose it)
            if (pair[0] === 'x-set-cookie') {
                // Original Set-Cookie may merge multiple headers, we have it packed
                response_headers['Set-Cookie'] = JSON.parse(pair[1]);
            }
            else {
                response_headers[pair[0]] = pair[1];
            }
        }
    
        const redirect_hack_url_prefix = `${location.origin.toString()}/redirect-hack.html?id=`;
    
        // Handler 301, 302, 307 edge case
        if(response.url.startsWith(redirect_hack_url_prefix)) {`

As you can see, I can't find the redirectUrl in the response

onemetafox avatar Jun 20 '23 21:06 onemetafox