Env swap #21

Merged
danieljsummers merged 30 commits from env-swap into help-wanted 2021-08-10 03:23:50 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 65e23a5b03 - Show all commits

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()}`
}
}