const app = express();
let keywords
app.get("/api/getNews", (req, res) => {
keywords = req.query.keywords
console.log(keywords)
getNewsFromSql(function () {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
res.send(resp)//
});
});
const server = app.listen(3000, function () {
const host = server.address().address;
const port = server.address().port;
console.log("Example server listening at http://%s:%s", host, port)
})
currently, you can listen to the get request of http on port 3000 and check the library.
is that the front end may run on the https server, and the browser ajax refuses to request the interface of http. The purpose of
is to listen for https request.
now the server already has a free certificate from Symantec. Online tutorials basically create self-signed certificates through openssl.
how to create a https interface with existing certificates in express?