zolrath / obsidian-auto-link-title

Automatically fetch the titles of pasted links
MIT License
415 stars 55 forks source link

Remove vulnerabilities & avoid the CORS issue by replacing `fetch` with `requestUrl` #88

Closed RyotaUshio closed 6 months ago

RyotaUshio commented 9 months ago

Hi, thank you for making this awesome plugin!

Remove vulnerabilities

npm install told me there are 2 high severity vulnerabilities. I found obsidian is outdated (older than 1.0.0), so I updated it. Then, the vulnerabilities have gone.

Avoid the CORS issue

Sometimes, pasting a URL causes the following error:

Access to fetch at 'https://genius.com/25251' from origin 'app://obsidian.md' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

So I replaced fetch() in scrapper.ts with Obsidian API's requestUrl.

"Similar to fetch(), request a URL using HTTP/HTTPS, without any CORS restrictions."

After this change, the error message's gone.

zolrath commented 6 months ago

Thanks for the PR! Sorry for the delay but it looks like this has been superseded by #91 so your fixes are in - in spirit!