Skip to content

Commit

Permalink
Merge pull request #14 from tacobell1896/feat/add-cors-for-client
Browse files Browse the repository at this point in the history
add cors to api
  • Loading branch information
tacobell1896 authored May 15, 2024
2 parents 913efb1 + 76a38f2 commit b51926c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
using Microsoft.Extensions.Configuration;
using Microsoft.CodeAnalysis.CSharp.Syntax;

var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddCors(options =>
{
options.AddPolicy(name: MyAllowSpecificOrigins,
builder =>
{
builder.WithOrigins("http://localhost:4200")
.AllowAnyHeader()
.AllowAnyMethod();
});
});

builder.Services.AddControllers();
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<SavePointContext>(options =>
Expand Down Expand Up @@ -44,6 +56,8 @@

app.UseHttpsRedirection();

app.UseCors(MyAllowSpecificOrigins);

app.UseAuthorization();

app.MapControllers();
Expand Down

0 comments on commit b51926c

Please sign in to comment.