[英]Http failure response for (unknown url): 0 Unknown Error - Only on Angular 5
[英]Error Code: 0 ExceptionMessage: Http failure response for (unknown url): 0 Unknown Error in Angular 5
我在我的 Angular 5 項目中收到此錯誤“錯誤代碼:0 ExceptionMessage:Http 失敗響應(未知 URL):0 未知錯誤”。
但是,我無法重新創建此問題,我在 Rollbar 錯誤日志中看到了此重復問題。 我在本地機器上嘗試了相同的步驟,還嘗試在不同的瀏覽器(如 chrome、safari 等)中重新創建,但沒有運氣。
我正在使用 AWS lambda 和 .NET 核心 2.1、API 代理網關和 ZC31C335EF37283C1Z51B1 上的 Front8.
AngularJs代碼
getOrgPublicAssetName(id: number): Observable<any> {
let content = this.appSharedService.getSitecontents();
if (content !== '')
return Observable.of(content);
if (id !== undefined)
return <Observable<any>>(
this.httpClient
.get(this.organizationUrl + '/SiteContent/' + id)
.map(result => {
this.appSharedService.setsitecontents(result);
return result;
})
.pipe(catchError(this.exceptionService.catchBadResponse))
);
else return Observable.of();
}
以下是我的 startup.cs 配置 function,我已經在使用 cors。
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseXRay("Organizations");
app.UseMiddleware(typeof(ErrorHandlingMiddleware));
Environment.SetEnvironmentVariable(EnvironmentVariableAWSRegion.ENVIRONMENT_VARIABLE_REGION, Configuration["AWS:Region"]);
// Create a logging provider based on the configuration information passed through the appsettings.json
// You can even provide your custom formatting.
loggerFactory.AddLambdaLogger(Configuration.GetLambdaLoggerOptions());
//Enable swagger endpoint if the environment is not production
if (!IsProductionEnvironment)
{
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
if (env.EnvironmentName == "Local")
c.SwaggerEndpoint(SwaggerLocalEndpoint, ApiName);
else
c.SwaggerEndpoint(SwaggerEndpoint, ApiName);
});
}
app.UseCors(policy =>
{
//TODO: This has to be addressed once we deploy both api and ui under the same domain
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
policy.WithExposedHeaders("WWW-Authenticate");
policy.WithExposedHeaders("X-Total-Count");
});
app.UseAuthentication();
app.UseMvc(routeBuilder =>
{
routeBuilder.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
routeBuilder.MapODataServiceRoute("odata", "odata", OrganizationModelBuilder.GetEdmModel());
});
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseResponseCaching();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.