Add CORS configurations
This commit is contained in:
parent
7fca559550
commit
8cf7982c1f
@ -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>]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user