node.js - 在 Electron 应用程序的生产环境中表达本地主机 URL
问题描述
我正在构建一个使用 Express 服务器来允许访问本地文件系统的 Electron 应用程序。
在本地开发时,Express 使用localhost:3000
默认 URL,并且 React 前端和 Express/Node 服务器之间的所有 API 交互都localhost
在 URL 中发送,如下所示:
// Call getHistory in server.js
fetch(`http://localhost:3000/getHistory?file=${file}`)
.then((data) => data.json())
.then(function(data) {
this.resizeImage(data.file);
})
.catch(function(error) {
console.log(error);
});
我不明白什么时候需要打包应用程序以进行生产,我该如何处理 localhost url?
我假设该应用程序不应在端口上运行,:3000
因为其他应用程序可能已经在使用此端口。
解决方案
推荐阅读
- oop - 为什么 .__index 只返回子类而不是基类的函数
- pandas - 通过基于文本相似性查看多列字段来合并两个熊猫数据框
- timeout - Hystrix 配置:isolation.thread.timeoutInMilliseconds
- laravel - “您要查找的资源已被删除、名称已更改或暂时不可用”Azure 上的 Laravel
- node.js - 我在 ./node_modules/@coreui/angular/fesm5/coreui-angular.js 493:33-51 "export 'ɵɵdefineInjectable' is not found in '@angular/core' 中收到警告
- jira - jira 云实例中问题附件的临时链接/url
- c# - 如何使 Ibeacon estimode 统一检测所有信标
- python - 在 Keras 中进行 BatchNorm 配置编辑后无法重新加载模型
- character - ~|的意思 以 Common Lisp 格式
- ssl - 将“A”记录作为子域添加到 IP 会删除 HTTPS?