From 65e23a5b039b4f2dc6bc4a5248e21f4d6d3900b0 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Fri, 23 Jul 2021 20:52:13 -0400 Subject: [PATCH] Minor WIP on NAS log on --- src/JobsJobsJobs/Api/App.fs | 2 ++ src/JobsJobsJobs/App/src/api/index.ts | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/JobsJobsJobs/Api/App.fs b/src/JobsJobsJobs/Api/App.fs index e6c8e65..8b4a3f7 100644 --- a/src/JobsJobsJobs/Api/App.fs +++ b/src/JobsJobsJobs/Api/App.fs @@ -12,6 +12,7 @@ open Giraffe.EndpointRouting /// Configure the ASP.NET Core pipeline to use Giraffe let configureApp (app : IApplicationBuilder) = app + .UseCors(fun p -> p.AllowAnyOrigin() |> ignore) .UseRouting() .UseEndpoints(fun e -> e.MapGiraffeEndpoints Handlers.allEndpoints) |> ignore @@ -25,6 +26,7 @@ let configureServices (svc : IServiceCollection) = svc.AddGiraffe () |> ignore svc.AddSingleton SystemClock.Instance |> ignore svc.AddLogging () |> ignore + svc.AddCors () |> ignore let svcs = svc.BuildServiceProvider() let cfg = svcs.GetRequiredService().GetSection "Rethink" let log = svcs.GetRequiredService().CreateLogger (nameof Data.Startup) diff --git a/src/JobsJobsJobs/App/src/api/index.ts b/src/JobsJobsJobs/App/src/api/index.ts index e81ce88..39f72ba 100644 --- a/src/JobsJobsJobs/App/src/api/index.ts +++ b/src/JobsJobsJobs/App/src/api/index.ts @@ -5,7 +5,7 @@ import { LogOnSuccess } from './types' * @param url The partial URL for the API * @returns A full URL for the API */ -const apiUrl = (url : string) : string => `/api/${url}` +const apiUrl = (url : string) : string => `http://localhost:5000/api/${url}` export default { @@ -15,10 +15,9 @@ export default { * @returns The user result, or an error */ logOn: async (code : string) : Promise => { - const resp = await fetch(apiUrl(`/citizen/log-on/${code}`), { method: 'GET' }) + const resp = await fetch(apiUrl(`citizen/log-on/${code}`), { method: 'GET', mode: 'cors' }) if (resp.status === 200) return await resp.json() as LogOnSuccess - console.error(await resp.text()) - return 'Error logging on' + return `Error logging on - ${await resp.text()}` } }