ItzCrazyKns / Perplexica

Perplexica is an AI-powered search engine. It is an Open source alternative to Perplexity AI
MIT License
16.46k stars 1.54k forks source link

Accessing Perplexica at least within LAN should be allowed #136

Closed tcsenpai closed 6 months ago

tcsenpai commented 6 months ago

Is your feature request related to a problem? Please describe. Accessing Perplexica at least within LAN should be allowed

Describe the solution you'd like Solving the "Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. " related to CORS cross origin issues (can be seen in the browser console when loading the frontend from another PC in the same network)

Describe alternatives you've considered /

Additional context It's just the CORS configuration that is missing (or by the way the root of the CORS problem), I think it would be nice to be able to either access Perplexica from LAN and/or use proxies (like cloudflare) to be able to access it on the go.

ItzCrazyKns commented 6 months ago

I don't think it should cause any CORS errors as we've complemented CORS in the application and allows all requests. Can you provide a screenshot of what exactly the browser's console says so I can look forward into this. Additionally it works completely fine on LAN (I've tested it myself).

tcsenpai commented 6 months ago

In a way, happy to hear that! I am glad is a local problem I can solve : ) Screenshot attached!

Unfortunately is in Italian but the translation goes

Blocked multi-origin request (cross-origin): the matching criterion of origin does not allow reading of the remote resource from http://127.0.0.1:3001/api/models. Reason: CORS request failed. Status code: (null).

I just noticed that the logs says 127.0.0.1, even tough in the docker-compose.yaml file I set perplexica-frontend to have the public api and ws url on 192.168.X.X

Additional notes: the same happens both on Firefox (with a lot of privacy extensions), Firefox without extensions and Chromium based browsers

Ps. the same behavior can be seen when I set up a cloudflare tunnel and i access it. For reference: I am using the docker-compose on Windows (unfortunately) and logs are silent.

immagine

tcsenpai commented 6 months ago

Update: my bad, I must have forgotten to rebuild the docker containers. For anyone struggling with this:

docker compose build && docker compose up -d

bigsk1 commented 6 months ago

same issue had to change to device ip on network, and ollama is running on another device on network, must rebuild and not docker compose up -d