nfriedly/node-unblocker

use node-unblocker in client sveltekit without node js

bobwatcherx opened this issue · 1 comments

i have problem how to use node-unblocker without node js . or server .
and use in client only
give me code and fix it


import Unblocker from 'unblocker'

import cheerio from 'cheerio'
import axios from 'axios'

let unblocker = new Unblocker({prefix: '/proxy/'});
export async function load() {
    let url = unblocker  + "http://javhd.today/"
    // let url = "https://jsonplaceholder.typicode.com/todos/1"
    console.log(url)
    try {
        // Fetching HTML content of the website
        const response = await axios.get(url);
        
        // Load HTML content into cheerio for parsing
        const $ = cheerio.load(response.data);
        // console.log(response.data)
        
    } catch (error) {
        console.error("Error fetching or parsing data:", error);
       
    }
}

error
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError],
socket: [Function: handleRequestSocket]
},
_eventsCount: 3,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'http:',
path: "/function%20handleRequest(clientRequest,%20clientResponse,%20next)%20%7B%20%20%20%20const%20data%20=%20initData(clientRequest,%20clientResponse);%20%20%20%20clientScriptsServer(clientRequest,%20clientResponse,%20(err)%20=%3E%20%7B%20%20%20%20%20%20if%20(err)%20return%20next(err);%20%20%20%20%20%20clientResponse.redirectTo%20=%20redirectTo.bind(%20%20%20%20%20%20%20%20redirectTo,%20%20%20%20%20%20%20%20clientRequest,%20%20%20%20%20%20%20%20clientResponse%20%20%20%20%20%20);%20%20%20%20%20%20if%20(!next)%20%7B%20%20%20%20%20%20%20%20next%20=%20function%20()%20%7B%20%20%20%20%20%20%20%20%20%20clientResponse.writeHead(400);%20%20%20%20%20%20%20%20%20%20clientResponse.end(%22Unable%20to%20process%20request%22);%20%20%20%20%20%20%20%20%7D;%20%20%20%20%20%20%7D%20%20%20%20%20%20const%20formatted%20=%20data.url;%20%20%20%20%20%20const%20raw%20=%20data.rawUrl;%20%20%20%20%20%20if%20(formatted)%20%7B%20%20%20%20%20%20%20%20//%20If%20the%20raw%20URL%20isn't%20quite%20right,%20but%20we%20can%20figure%20it%20out,%20redirect%20to%20the%20correct%20URL.%20%20%20%20%20%20%20%20//%20Special%20exception%20for%20cases%20where%20routers%20collapsed%20slashes%20(see%20",
method: 'GET',
headers: [Object: null prototype],
agents: [Object],
auth: undefined,
family: undefined,
beforeRedirect: [Function: dispatchBeforeRedirect],
beforeRedirects: [Object],
hostname: 'localhost',
port: '',
agent: undefined,
nativeProtocols: [Object],

Closing as unfeasible. See discussion at #252 (comment)