Can't read custom header in HttpResponse from HttpClient in a Ionic Angular application

前端 未结 3 1665
名媛妹妹
名媛妹妹 2020-12-03 08:48

I\'m requesting an endpoint that creates a new resource and returns a 201 response containing a \"Location\" header with the newly created resource:

However

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 09:21

            Response.Headers.Append("myCaptchaName", "value");
    
    
    services.AddCors(options =>
            {
                options.AddPolicy("AllowMyOrigin",
                    builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader().
                    AllowAnyMethod().AllowCredentials()
                    .WithExposedHeaders("myCaptchaName"));
            });
            services.Configure(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory("AllowMyOrigin"));
            });
    

提交回复
热议问题