Add CORS configurations
This commit is contained in:
parent
7fca559550
commit
8cf7982c1f
@ -1,4 +1,5 @@
|
|||||||
open Microsoft.AspNetCore.Builder
|
open Microsoft.AspNetCore.Builder
|
||||||
|
open Microsoft.AspNetCore.Cors.Infrastructure
|
||||||
open Microsoft.AspNetCore.Hosting
|
open Microsoft.AspNetCore.Hosting
|
||||||
open Microsoft.Extensions.Hosting
|
open Microsoft.Extensions.Hosting
|
||||||
open Microsoft.Extensions.DependencyInjection
|
open Microsoft.Extensions.DependencyInjection
|
||||||
@ -32,14 +33,28 @@ let endpointsList = [
|
|||||||
|
|
||||||
(* Infrastructure Configuration *)
|
(* 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) =
|
let configureApp (app : IApplicationBuilder) =
|
||||||
app
|
app
|
||||||
.UseRouting()
|
.UseRouting()
|
||||||
|
.UseCors(configureCors)
|
||||||
.UseEndpoints(fun e -> e.MapGiraffeEndpoints(endpointsList))
|
.UseEndpoints(fun e -> e.MapGiraffeEndpoints(endpointsList))
|
||||||
|> ignore
|
|> ignore
|
||||||
|
|
||||||
|
|
||||||
let configureServices (services : IServiceCollection) =
|
let configureServices (services : IServiceCollection) =
|
||||||
// Add Giraffe dependencies
|
// Add Giraffe dependencies
|
||||||
|
services.AddCors() |> ignore
|
||||||
services.AddGiraffe() |> ignore
|
services.AddGiraffe() |> ignore
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user