【问题标题】:The front-end cannot accept the page returned by the back-end route前端无法接受后端路由返回的页面
【发布时间】:2023-03-29 00:10:02
【问题描述】:

后台路由跳转到前端返回页面时,遇到下载页面文件的情况。

enter image description here

enter image description here 点击时,浏览器会自动下载post.html

【问题讨论】:

    标签: html express router


    【解决方案1】:

    尝试使用res.send 或直接使用res.sendFile

    https://expressjs.com/en/api.html#res.send

    【讨论】:

    • 感谢您的回答。我发现当我在 res.render 之前添加 res.set('Content-Type','text/html;charset=utf-8') 时,前端可以获得正确的响应。我猜响应头的默认值不是 res.render() 中的正确选项。
    猜你喜欢
    • 1970-01-01
    • 2020-11-07
    • 1970-01-01
    • 2010-12-14
    • 2017-12-20
    • 2016-01-29
    • 2021-05-05
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多