editor-js / link

Link Tool for Editor.js 2.0
MIT License
92 stars 79 forks source link

Endpoint async functions instead of URL #45

Open ngmiduc opened 3 years ago

ngmiduc commented 3 years ago

Hi,

is it also possible to put an async function as the endpoint instead of haveing a URL ?

PythonLinks commented 2 years ago

I think not. It has to do with CORS, cross site scriptiong. the browser does not let you access one site from another, unless the other explicitely allows it.

Having said that, what confuses me is how it accesses the image. With the fetchUrl argument, I return the image url, somehow it grabs that, but it is not allowed to do so in general. I guess I will be reading the code in greater depth, to see what magic they do, and maybe to make some upgrades.

Thanks for the brilliant work, guys in St. Petersburg (and elsewhere).

Akash187 commented 2 years ago

@PythonLinks you missed the point that @ngmiduc is trying to make. Actually, he wants to manage making request on his own. Similar to Image plugin. Currently, I am facing an issue where I have my auth token stored in cookies. Which automatically gets sent to the backend with every request that I make using Axios. Since cookies are protected by HTTP: only I can't access them with javascript and set it on headers.

calumk commented 1 year ago

This is really needed

Format could be like this

LinkTool : {
    class : LinkTool,
    config : {
        endpointAsync  = (url) => {
               return // some function that somes something with url
        }
    }
}
ngmiduc commented 1 year ago

@PythonLinks you missed the point that @ngmiduc is trying to make. Actually, he wants to manage making request on his own. Similar to Image plugin. Currently, I am facing an issue where I have my auth token stored in cookies. Which automatically gets sent to the backend with every request that I make using Axios. Since cookies are protected by HTTP: only I can't access them with javascript and set it on headers.

Yes sorry for the unclear issue. Yes, I wanted to manage the request by my own.

Abhii5496 commented 8 months ago

This is really needed

Format could be like this

LinkTool : {
    class : LinkTool,
    config : {
        endpointAsync  = (url) => {
               return // some function that somes something with url
        }
    }
}

i have the same issue , this would be great if we just get the url do whatever we want with it