Angular 2加载本地json文件403 forbidden error



从我在web上看到的例子来看似乎很简单,但是当我试图从我的Angular 2应用程序中加载本地json文件到我的服务中时。我得到一个403禁止错误。我的应用程序在Servicestack自托管服务中运行。工作正常,当我做一个请求,如http://localhost:8087/customers/,但相同的数据在本地json文件在我的应用程序目录将不会(http://localhost:8087/app/customers.json)

我需要做什么来允许我的应用程序访问该文件?

this._http.get('app/customers.json').toPromise()
        .then(function (response) {
            console.log(JSON.stringify(response))
        }).catch(this.handleError);

来自@mythz的建议修复了我的问题。我在我的appHost文件中添加了这一行。

HostConfig.Instance.AllowFileExtensions.Add("json");

相关内容

最新更新