Pages CORS issue when communicating with Llama API

Hi, I have written a Vue 3 app which uses Vite to talk to the Llama AI worker. This works fine when running locally via the vite dev server as I am using a proxy however, after deploying to Cloudflare Pages, my requests are no longer proxied via the Vite dev server so the requests are going to the Llama AI but the OPTIONS request comes back with a 400 error. Any ideas how I can get this working correctly? Appologies if this needs posing in the Pages section of Discord - it's cross product so felt this was a better place as the issue is with talking from CF Pages to the CF AI
1 Reply
Crystal Shardz
Crystal ShardzOP5mo ago
Looks like a solution was found by a colleague of mine. Instead of querying Llama's API directly from the Pages JAvascript, we used a worker instead as a middle man to send the response from our front end to Llama and then back to the front end.
Want results from more Discord servers?
Add your server