[英]Angular 2 Electron - Consuming REST-API
I have an Electron App, which uses Angular 2 - in order to work i needed to modify <base href="/">
to <base href="./">
, which is a relative path in the file system. 我有一个Electron App,它使用Angular 2 - 为了工作我需要将
<base href="/">
修改为<base href="./">
,这是文件系统中的相对路径。 But now the API doesn't work anymore (Webclient on localhost works fine, but not Electron Client). 但现在API不再起作用了(localhost上的Webclient工作正常,但不是Electron Client)。
I access the API via proxy.conf.json 我通过proxy.conf.json访问API
{
"/api": {
"target": "http://127.0.0.1:4747/Ticketsale",
"secure": false
}
}
And the error message in the JavaScript Console of Chromium / Electron is: Chromium / Electron的JavaScript控制台中的错误消息是:
file:///Users/myusername/folder/apps/officeclient_electron/office-client-darwin-x64/office-client.app/Contents/Resources/app/api/1/initialData
Failed to load resource: net::ERR_FILE_NOT_FOUND
How can i tell Electron to access the local resources via relative Path and consume the API via HTTP? 我怎样才能告诉Electron通过相对Path访问本地资源并通过HTTP使用API?
We enabled CORS on the Webserver and this setting allowed us to consume the REST-API from a different URL. 我们在Web服务器上启用了CORS,这个设置允许我们从不同的URL使用REST-API。
See https://en.wikipedia.org/wiki/Cross-origin_resource_sharing for details. 有关详细信息,请参阅https://en.wikipedia.org/wiki/Cross-origin_resource_sharing 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.