Just tested this and noticed it does a OPTIONS "/api/generate" request. From what I can tell this doesn't exist in latest ollama code...
Thoughts?
Originally created by @Chillance on GitHub (Oct 17, 2023).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/2
Originally assigned to: @tjbck on GitHub.
Hi!
Just tested this and noticed it does a OPTIONS "/api/generate" request. From what I can tell this doesn't exist in latest ollama code...
Thoughts?
Browsers often send an OPTIONS request to verify CORS, which might be the case here. Were there any other issues caused by the OPTIONS request?
Thanks.
<!-- gh-comment-id:1767424903 -->
@tjbck commented on GitHub (Oct 18, 2023):
Hi there,
Browsers often send an OPTIONS request to verify CORS, which might be the case here. Were there any other issues caused by the OPTIONS request?
Thanks.
Well, I get that asking something trying to generate something, but it seems to stop there so nothing else happens.
<!-- gh-comment-id:1769375294 -->
@Chillance commented on GitHub (Oct 18, 2023):
Well, I get that asking something trying to generate something, but it seems to stop there so nothing else happens.
Could you please provide any specific error messages or logs that you encounter during the process? This information would greatly assist me in diagnosing the problem more accurately and providing you with the appropriate guidance.
Thanks.
<!-- gh-comment-id:1769460511 -->
@tjbck commented on GitHub (Oct 18, 2023):
Could you please provide any specific error messages or logs that you encounter during the process? This information would greatly assist me in diagnosing the problem more accurately and providing you with the appropriate guidance.
Thanks.
How do I get better logs? I tried typing something, pressed enter, and then nothing.
<!-- gh-comment-id:1770556868 -->
@Chillance commented on GitHub (Oct 19, 2023):
How do I get better logs? I tried typing something, pressed enter, and then nothing.
To obtain more detailed logs, you can use the following command for Docker:
docker logs ollama-webui
Additionally, it would be helpful for diagnosing your issue if you could provide a screenshot of your console logs from your browser's developer tools. This will allow us to examine any client-side errors or issues that might not be visible in the server logs.
Please feel free to share the Docker logs and the browser console logs screenshot, and we'll do our best to assist you in resolving the problem.
Thanks.
<!-- gh-comment-id:1771684144 -->
@tjbck commented on GitHub (Oct 19, 2023):
Hi there,
To obtain more detailed logs, you can use the following command for Docker:
```bash
docker logs ollama-webui
```
Additionally, it would be helpful for diagnosing your issue if you could provide a screenshot of your console logs from your browser's developer tools. This will allow us to examine any client-side errors or issues that might not be visible in the server logs.
Please feel free to share the Docker logs and the browser console logs screenshot, and we'll do our best to assist you in resolving the problem.
Thanks.
@Chillance Part of the reason that browsers invented CORS Preflight Requests (the OPTIONS issue) is to prevent people from stumbling into security issues.
Do you already have the access protected with an API token or HTTP Basic Auth?
<!-- gh-comment-id:1773884703 -->
@coolaj86 commented on GitHub (Oct 21, 2023):
@Chillance Part of the reason that browsers invented CORS Preflight Requests (the OPTIONS issue) is to prevent people from stumbling into security issues.
Do you already have the access protected with an API token or HTTP Basic Auth?
Check out https://github.com/jmorganca/ollama/issues/849#issuecomment-1773697189 and the CORS section at https://webinstall.dev/caddy.
I don't do anything particular but just staring the ollama serve. And, on the same machine I run this in docker.
docker run --network=host -p 3000:3000 --name ollama-webui --restart always ollama-webui
I actually got chatbot-ollama (other repo) working fine. But here I can see this in the console log:
e87e0c1f-4d67-4015-959a-0e2b59659483
2.fb1b6367.js:52 submitPrompt
192.168.1.11/:1 Access to fetch at 'http://192.168.1.11:11434/api/generate' from origin 'http://192.168.1.11:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
start.93b882e2.js:1
POST http://192.168.1.11:11434/api/generate net::ERR_FAILED
window.fetch @ start.93b882e2.js:1
R @ 2.fb1b6367.js:52
await in R (async)
re @ 2.fb1b6367.js:58
start.93b882e2.js:1
Uncaught (in promise) TypeError: Failed to fetch
at window.fetch (start.93b882e2.js:1:1402)
at R (2.fb1b6367.js:52:108120)
<!-- gh-comment-id:1774207623 -->
@Chillance commented on GitHub (Oct 22, 2023):
I don't do anything particular but just staring the ollama serve. And, on the same machine I run this in docker.
`docker run --network=host -p 3000:3000 --name ollama-webui --restart always ollama-webui`
I actually got chatbot-ollama (other repo) working fine. But here I can see this in the console log:
>
> e87e0c1f-4d67-4015-959a-0e2b59659483
> 2.fb1b6367.js:52 submitPrompt
> 192.168.1.11/:1 Access to fetch at 'http://192.168.1.11:11434/api/generate' from origin 'http://192.168.1.11:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
> start.93b882e2.js:1
>
> POST http://192.168.1.11:11434/api/generate net::ERR_FAILED
> window.fetch @ start.93b882e2.js:1
> R @ 2.fb1b6367.js:52
> await in R (async)
> re @ 2.fb1b6367.js:58
> start.93b882e2.js:1
>
> Uncaught (in promise) TypeError: Failed to fetch
> at window.fetch (start.93b882e2.js:1:1402)
> at R (2.fb1b6367.js:52:108120)
And docker logs ollama-webui
only returns: Listening on 0.0.0.0:3000
<!-- gh-comment-id:1774208331 -->
@Chillance commented on GitHub (Oct 22, 2023):
And
`docker logs ollama-webui`
only returns:
`Listening on 0.0.0.0:3000`
Your logs confirm the CORS error as expected, you should pull the latest commit of the main branch and build the docker container. It introduces breaking changes so your command should be replaced with the following instead:
Also make sure to run the following command to serve Ollama, as mentioned here, which should solve your issue:
OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve
Thanks.
<!-- gh-comment-id:1774211533 -->
@tjbck commented on GitHub (Oct 22, 2023):
Your logs confirm the CORS error as expected, you should pull the latest commit of the main branch and build the docker container. It introduces breaking changes so your command should be replaced with the following instead:
```sh
docker build --build-arg OLLAMA_API_BASE_URL='' -t ollama-webui .
docker run -d -p 3000:8080 --name ollama-webui --restart always ollama-webui
```
Also make sure to run the following command to serve Ollama, as mentioned [here](https://github.com/ollama-webui/ollama-webui#accessing-ollama-web-interface-over-lan), which should solve your issue:
```sh
OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve
```
Thanks.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @Chillance on GitHub (Oct 17, 2023).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/2
Originally assigned to: @tjbck on GitHub.
Hi!
Just tested this and noticed it does a OPTIONS "/api/generate" request. From what I can tell this doesn't exist in latest ollama code...
Thoughts?
@tjbck commented on GitHub (Oct 18, 2023):
Hi there,
Browsers often send an OPTIONS request to verify CORS, which might be the case here. Were there any other issues caused by the OPTIONS request?
Thanks.
@Chillance commented on GitHub (Oct 18, 2023):
Well, I get that asking something trying to generate something, but it seems to stop there so nothing else happens.
@tjbck commented on GitHub (Oct 18, 2023):
Could you please provide any specific error messages or logs that you encounter during the process? This information would greatly assist me in diagnosing the problem more accurately and providing you with the appropriate guidance.
Thanks.
@Chillance commented on GitHub (Oct 19, 2023):
How do I get better logs? I tried typing something, pressed enter, and then nothing.
@tjbck commented on GitHub (Oct 19, 2023):
Hi there,
To obtain more detailed logs, you can use the following command for Docker:
Additionally, it would be helpful for diagnosing your issue if you could provide a screenshot of your console logs from your browser's developer tools. This will allow us to examine any client-side errors or issues that might not be visible in the server logs.
Please feel free to share the Docker logs and the browser console logs screenshot, and we'll do our best to assist you in resolving the problem.
Thanks.
@coolaj86 commented on GitHub (Oct 21, 2023):
@Chillance Part of the reason that browsers invented CORS Preflight Requests (the OPTIONS issue) is to prevent people from stumbling into security issues.
Do you already have the access protected with an API token or HTTP Basic Auth?
Check out https://github.com/jmorganca/ollama/issues/849#issuecomment-1773697189 and the CORS section at https://webinstall.dev/caddy.
@coolaj86 commented on GitHub (Oct 21, 2023):
Tested, Working Example
See #10
@Chillance commented on GitHub (Oct 22, 2023):
I don't do anything particular but just staring the ollama serve. And, on the same machine I run this in docker.
docker run --network=host -p 3000:3000 --name ollama-webui --restart always ollama-webuiI actually got chatbot-ollama (other repo) working fine. But here I can see this in the console log:
@Chillance commented on GitHub (Oct 22, 2023):
And
docker logs ollama-webuionly returns:
Listening on 0.0.0.0:3000@tjbck commented on GitHub (Oct 22, 2023):
Your logs confirm the CORS error as expected, you should pull the latest commit of the main branch and build the docker container. It introduces breaking changes so your command should be replaced with the following instead:
Also make sure to run the following command to serve Ollama, as mentioned here, which should solve your issue:
Thanks.
@Chillance commented on GitHub (Oct 25, 2023):
Thanks! Works now!