1
0

Add CORS configurations

This commit is contained in:
PA4KEV 2023-06-26 21:38:07 +02:00
parent 7fca559550
commit 8cf7982c1f

View File

@ -1,4 +1,5 @@
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Cors.Infrastructure
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.DependencyInjection
@ -32,14 +33,28 @@ let endpointsList = [
(* Infrastructure Configuration *)
let configureCors (builder : CorsPolicyBuilder) =
builder
.WithOrigins(
"http://localhost:5218",
"https://localhost:5218",
"http://localhost:3000",
"https://localhost:3000")
.AllowAnyMethod()
.AllowAnyHeader()
|> ignore
let configureApp (app : IApplicationBuilder) =
app
.UseRouting()
.UseCors(configureCors)
.UseEndpoints(fun e -> e.MapGiraffeEndpoints(endpointsList))
|> ignore
let configureServices (services : IServiceCollection) =
// Add Giraffe dependencies
services.AddCors() |> ignore
services.AddGiraffe() |> ignore
[<EntryPoint>]