Skip to content
Snippets Groups Projects

Sæt CORS header

The snippet can be accessed without any authentication.
Authored by Peter Ravnholt

Sætter CORS header for et backend api. Her tillades alle type headers og http verbs, men kun fra et bestemt domæne.

Startup.cs 217 B
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseCors(cors =>
        cors.AllowAnyHeader()
            .AllowAnyMethod()
            .WithOrigins(new[] { "audomain.dk" }));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment