elm授权服务器无响应,尽管在Elm和长颈鹿中启用了CORS,但Http Post的问题

榆树(客户端):

tryPostRegistration : String -> Http.Body -> Decoder JsonProfile -> Http.Request JsonProfile

tryPostRegistration url body decoder =

Http.request

{ method = "POST"

, headers =

[ header "Origin" "http://elm-lang.org"

, header "Access-Control-Request-Method" "POST"

, header "Access-Control-Request-Headers" "X-Custom-Header"

]

, url = url

, body = body

, expect = Http.expectJson decoder

, timeout = Nothing

, withCredentials = False

}

tryRegister : Form -> (Result Http.Error JsonProfile -> msg) -> Cmd msg

tryRegister form msg =

let

url =

baseUrl ++ "register"

body =

encodeRegistration form |> Http.jsonBody

request =

tryPostRegistration url body profileDecoder

in

Http.send msg request

错误(榆树客户端):

HTTP404:NOT FOUND - 服务器没有找到任何匹配 请求的URI(统一资源标识符)(XHR)选项 - http://localhost:5000/register

长颈鹿(服务器):

let configureCors (builder : CorsPolicyBuilder) =

builder.WithOrigins("http://localhost:5000").AllowAnyMethod().AllowAnyHeader() |> ignore

let configureApp (app : IApplicationBuilder) =

app.UseCors configureCors |> ignore

app.UseGiraffe webApp

let configureServices (services : IServiceCollection) =

...

services.AddCors |> ignore // Enables CORS

错误(长颈鹿服务器):

DBUG:Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware 1 OPTIONS请求不被支持

dbug:Giraffe.Middleware.GiraffeMiddleware [0] 长颈鹿回归斯内德对于一些HTTP/1.1 OPTIONS /注册

附录:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值