Minor WIP on NAS log on

This commit is contained in:
Daniel J. Summers 2021-07-23 20:52:13 -04:00
parent 4fce076ee5
commit 65e23a5b03
2 changed files with 5 additions and 4 deletions

View File

@ -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<IClock> SystemClock.Instance |> ignore
svc.AddLogging () |> ignore
svc.AddCors () |> ignore
let svcs = svc.BuildServiceProvider()
let cfg = svcs.GetRequiredService<IConfiguration>().GetSection "Rethink"
let log = svcs.GetRequiredService<ILoggerFactory>().CreateLogger (nameof Data.Startup)

View File

@ -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<LogOnSuccess | string> => {
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()}`
}
}