# CORS Issue with Ollama and Zrok Proxy using Caddy on Flutter Web

**URL:** https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365
**Category:** zrok
**Created:** [November 4, 2024, 11:24pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365 "2024-11-04T23:24:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![gss214](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gss214/32/2696_2.png) [@gss214](https://openziti.discourse.group/u/gss214)
#### Post date: [November 4, 2024, 11:24pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/1 "2024-11-04T23:24:04Z")

</div>

Hello everyone,

I'm running into a CORS issue with my setup using Ollama for LLM processing, a Zrok proxy, and Caddy as the server. I'm building a Flutter Web app and using the ollama\_dart: ^0.2.0 package to make API calls.

Here is my `Caddyfile`:

```auto
# Global config must be first
{
    # No listen on 2019/tcp with admin API
    admin off
    debug
}

(cors) {
  @cors_preflight method OPTIONS
  @cors header Origin {args.0}

  handle @cors_preflight {
    header Access-Control-Allow-Origin "{args.0}"
    header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
    header Access-Control-Allow-Headers "Content-Type"
    header Access-Control-Max-Age "3600"
    respond "" 204
  }

  handle @cors {
    header Access-Control-Allow-Origin "{args.0}"
    header Access-Control-Expose-Headers "Link"
  }
}

# zrok site block
http:// {
    bind {{ .ZrokBindAddress }}
    import cors *
    reverse_proxy 127.0.0.1:11434 {
        header_up Host localhost:11434
    }
}

```

However, I'm seeing this CORS error in the browser:

```auto
Access to fetch at 'https://myzroketoken.share.zrok.io/api/chat' from origin 'http://localhost:49793' 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.

```

The preflight request details are as follows:

- Request URL: [https://myzroketoken.share.zrok.io/api/chat](https://myzroketoken.share.zrok.io/api/chat)
- Request Method: OPTIONS
- Status Code: 200 OK
- Access-Control-Request-Headers: content-type,skip\_zrok\_interstitial
- Access-Control-Request-Method: POST
- Origin: [http://localhost:49793](http://localhost:49793)

I've been trying to adjust the `Caddyfile` configuration to handle CORS properly, but I keep hitting this issue. Any advice on resolving this? Am I missing something in my CORS setup with Caddy or Zrok?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)
#### Post date: [November 5, 2024, 2:09pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/2 "2024-11-05T14:09:27Z")

</div>

Hi @gss214, welcome to the community and to zrok (and OpenZiti/BrowZer)!

The skip\_interstitial handling i **think** was updated recently. What version of zrok are you using? [CORS Issues with zrok - #8 by michael.quigley](https://openziti.discourse.group/t/cors-issues-with-zrok/3283/8)

---

<div class="post-metadata">

### Author: ![gss214](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gss214/32/2696_2.png) [@gss214](https://openziti.discourse.group/u/gss214)
#### Post date: [November 5, 2024, 2:52pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/3 "2024-11-05T14:52:23Z")

</div>

Hi, I'm using version v0.4.39, I'll try to update here and bring an update

---

<div class="post-metadata">

### Author: ![gss214](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gss214/32/2696_2.png) [@gss214](https://openziti.discourse.group/u/gss214)
#### Post date: [November 5, 2024, 3:35pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/4 "2024-11-05T15:35:39Z")

</div>

I updated to version v0.4.4 2 [ef1795f1], I used the reserve command to restart the proxy but the CORS error persists

---

<div class="post-metadata">

### Author: ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)
#### Post date: [November 5, 2024, 3:45pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/5 "2024-11-05T15:45:25Z")

</div>

This issue will be resolved when `v0.4.43` is promoted to production. Production is currently at `v0.4.42`.

```auto
$ curl https://api.zrok.io/api/v1/version
"v0.4.42 [ef1795f1]"

```

---

<div class="post-metadata">

### Author: ![gss214](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gss214/32/2696_2.png) [@gss214](https://openziti.discourse.group/u/gss214)
#### Post date: [November 5, 2024, 3:59pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/6 "2024-11-05T15:59:49Z")

</div>

Ahhh, I see, thanks. When will version 0.4.43 go to production?

---

<div class="post-metadata">

### Author: ![gss214](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gss214/32/2696_2.png) [@gss214](https://openziti.discourse.group/u/gss214)
#### Post date: [November 5, 2024, 11:20pm UTC](https://openziti.discourse.group/t/cors-issue-with-ollama-and-zrok-proxy-using-caddy-on-flutter-web/3365/7 "2024-11-05T23:20:08Z")

</div>

Just an update, I updated to version v0.4.44 [c527340c] and I still have the cors error ):

Edit: I have already put skip\_zrok interstitial in the header of every request. My flutter client looks like this:

```auto
client = ollama.OllamaClient(
        baseUrl: 'https://$zrokToken.share.zrok.io/api',
        headers: {'skip_zrok_interstitial': '1'},
      )

```
