Angular 2 Electron - 消耗 REST-API
Angular 2 Electron - Consuming REST-API
我有一个 Electron 应用程序,它使用 Angular 2 - 为了工作,我需要将 <base href="/">
修改为 <base href="./">
,这是文件系统中的相对路径。但是现在 API 不再工作了(本地主机上的 Webclient 工作正常,但 Electron Client 不工作)。
我通过 proxy.conf.json
访问 API
{
"/api": {
"target": "http://127.0.0.1:4747/Ticketsale",
"secure": false
}
}
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
如何告诉 Electron 通过相对路径访问本地资源并通过 HTTP 使用 API?
我们在 Web 服务器上启用了 CORS,此设置允许我们使用来自不同 URL.
的 REST-API
详情见https://en.wikipedia.org/wiki/Cross-origin_resource_sharing。
我有一个 Electron 应用程序,它使用 Angular 2 - 为了工作,我需要将 <base href="/">
修改为 <base href="./">
,这是文件系统中的相对路径。但是现在 API 不再工作了(本地主机上的 Webclient 工作正常,但 Electron Client 不工作)。
我通过 proxy.conf.json
访问 API{
"/api": {
"target": "http://127.0.0.1:4747/Ticketsale",
"secure": false
}
}
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
如何告诉 Electron 通过相对路径访问本地资源并通过 HTTP 使用 API?
我们在 Web 服务器上启用了 CORS,此设置允许我们使用来自不同 URL.
的 REST-API详情见https://en.wikipedia.org/wiki/Cross-origin_resource_sharing。