index.js内容
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello world");
});
app.all("*", function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By", " 3.2.1");
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
app.use("/public", express.static("./public"));
app.listen(4568, (req, res) => {
console.log(res);
console.log("Server is running at http://localhost:4568111");
});
然后将通过electon-builder和electron-updater打包出来的两个文件(一个执行文件另一个含有latest文件名的yml文件)放在自己创建public文件夹下就行了。
通过以上搭建的服务updateUrl为 http://localhost:4568/public
package.json内容
{
"name": "updateserver",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "yexianli",
"license": "ISC",
"dependencies": {
"express": "^4.10.8"
}
}