创建的应用需要将其传输到node.js
我在香草JS中创建了一个天气应用程序,并希望使用环境VAR,以便我可以隐藏我的API键。我发现env var在香草JS中不起作用,因此我希望将其转移到node.js,然后不适用于使用env var。 我做了很多研究,但仍在努力知道从哪里开始。有什么建议吗?
*node code*
const express = require("express");
const app = express();
require("dotenv").config();
// console.log(process.env);
app.get("/", (req, res) => {
res.sendFile("/Users/name/Desktop/Weather App/public/app.html");
});
// serve any HTML files located in /Users/name/Desktop/Weather App/public
app.use(express.static("/Users/name/Desktop/Weather App/public"));
app.listen(3000, () => {
console.log("listening at 3000");
});
非常感谢
Ive created a weather app in vanilla js and want to use environment var's so that I can hide my api keys. I have found that env var's don't work in vanilla js, so I am looking to transfer it over to node.js and then ill be able to use env var.
Ive done lots of research but still struggling to know where to start. Any suggestions?
*node code*
const express = require("express");
const app = express();
require("dotenv").config();
// console.log(process.env);
app.get("/", (req, res) => {
res.sendFile("/Users/name/Desktop/Weather App/public/app.html");
});
// serve any HTML files located in /Users/name/Desktop/Weather App/public
app.use(express.static("/Users/name/Desktop/Weather App/public"));
app.listen(3000, () => {
console.log("listening at 3000");
});
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论