Swaggeroo / obsidian-ai-image-analyzer

Analyze images with AI to get keywords of the image.
GNU General Public License v3.0
33 stars 0 forks source link

CORS Issue with AI Image Analyzer Plugin #30

Closed mathe00 closed 1 month ago

mathe00 commented 2 months ago

Description:

Hello,

I’m encountering a CORS-related issue when using the AI Image Analyzer plugin in Obsidian. The following error appears in the browser console when I try to analyze images through the local Ollama API:

Access to fetch at 'http://127.0.0.1:11434/api/pull' from origin 'app://obsidian.md' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

It seems that the Ollama API doesn’t allow requests from the app://obsidian.md origin, resulting in the CORS policy blocking the request.


What I’ve Tried:

  1. Using no-cors in fetch requests: I tried setting the request mode to no-cors to bypass the CORS policy. However, this limits the response data, making the plugin unusable for certain functions.

  2. Modifying API Origin Configuration: I attempted to manually add app://obsidian.md to the allowed origins for Ollama, but this did not resolve the issue.


Request for Improvement:

Could you provide support for allowing requests from app://obsidian.md in the Ollama API’s CORS headers? Alternatively, is there a way to configure this within the plugin to explicitly allow the origin? This would make the API usable within Obsidian’s local web application setup.


Thank you in advance for your assistance! Feel free to reach out if you need additional information or if I can assist with testing a solution.

Swaggeroo commented 1 month ago

You have to update your Ollama this should resolve the problem

Swaggeroo commented 1 month ago

Seems to be fixed