【发布时间】:2021-05-04 07:44:57
【问题描述】:
当我尝试使用 iframe 加载另一个(本地)网页时,express 无法加载 iframe 的内容
/index.html(加载器)
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Not important</title>
</head>
<body>
<iframe src="/pages/test.html" width="" height=""></iframe>
</body>
</html>
main.js
const express = require("express");
const app = express();
const port = 7077;
app.use("/", express.static("public"));
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
Error:
Cannot GET /test.html
文件层次结构:
project folder
| main.js
| public
| | index.html
| | pages
| | | test.html
| | |_
| |_
|_
编辑添加:如果我直接在我的网络浏览器中加载/pages/test.html,那效果很好。只是在 iframe 中时。
编辑:没关系。是 Firefox 的问题,而不是我的代码(耶?)
【问题讨论】:
标签: javascript node.js express http