dotnet / dotnet/aspnetcore

CORS - AnyOrigin & WithOrigins has no effect

Open
#63,120 10 comments 0 reactions 0 assignees View on GitHub
area-middleware feature-cors Needs: Attention :wave:
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

ConfigureServices:

services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.WithOrigins("http://192.168.3.9:8080")
.AllowAnyMethod()
.AllowAnyHeader());
});

Configure:

app.UseRouting();
app.UseCors("CorsPolicy");

Result:
Image

I also had the effect for a short time although it didn't work before, but then it suddenly worked.

I deleted the bin and obj folders and recompiled them..no effect

### Expected Behavior

That it works.

### Steps To Reproduce

- Create an separated api and blazor wasm client in .net 9
- Create an endpoint and connect to this on client side

### Exceptions (if any)

_No response_

### .NET Version

.net 9

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.