Use CORS for the proxy #436
-
Hello, I am using the proxy as it is described in the README. In a WebGL app which runs on a different domain than the proxy, I get CORS errors, trying to access the API. Is there a way to configure CORS in the proxy? I already tried different things but found no way. Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
sounds like a bit more complicated of a setup with proxy. I'd have to see the exact errors to help troubleshoot. The CORS error is coming form proxy or unity client? |
Beta Was this translation helpful? Give feedback.
-
The error comes from the client (in the web browser). //-- activate CORS (for our local testing)
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowOurSources", policy =>
{
policy.WithOrigins("http://localhost:8000", "https://my-test-domain.com") // Allow specific origin
.AllowAnyMethod() // Allow any HTTP method
.AllowAnyHeader(); // Allow any header
});
});
WebApplication app = builder.Build();
// Use the CORS policy
app.UseCors("AllowOurSources"); |
Beta Was this translation helpful? Give feedback.
-
I took the single file into my project, renamed the class to OpenAIProxy2 and patched it. That works. |
Beta Was this translation helpful? Give feedback.
You could just build it yourself and replace that call with your own version of the following:
OpenAI-DotNet/OpenAI-DotNet-Proxy/Proxy/OpenAIProxy.cs
Lines 87 to 96 in 2e53e8e
You don't have to use
OpenAiProxy.Crea…