node.js - 使用 ReactJS 表达不更新 get 函数
问题描述
我有一个运行良好的 express/react 应用程序,它是一个单页应用程序。我需要在服务器端对身份验证进行一些更改,但我注意到运行快速服务器我的应用程序没有提供更新的 .get 功能。关于为什么会发生这种情况的任何想法?
旧功能
app.get('/app/', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'))
})
新功能:
app.get('/app/', async (req, res) => {
const authorized = await checkSession(req)
if (!authorized) { res.redirect('/login'); return}
res.send("OK")
})
我想我应该OK
在浏览器中得到一个纯文本作为响应,但即使更改服务器端口、浏览器或任何我能想到的东西,我也会得到旧页面。任何帮助深表感谢。
解决方案
删除第一个参数的尾部斜杠app.get()
:
app.get('/app', async (req, res) => {
const authorized = await checkSession(req)
if (!authorized) { res.redirect('/login'); return}
res.send("OK")
})
推荐阅读
- git - 如何获得“有效”的 Git 忽略模式列表?
- bash - grep 文件 bash 中最后一次匹配与 nlines 之后的匹配
- sql-server - .NET Core API 未连接到在 Docker 上运行的 SQL Server
- firebase - 让ExpansionPanelList在Streambuilder中工作
- java - Android Lint:是否可以在 Maven 上的 jar 文件(不是 aar)中发布 lint 检查
- javascript - 获取 HashTable 的值
- node.js - 如何更新 mongodb atlas 文档中的值?
- javascript - If 语句 - Javascript/HTML 数学测验
- python - Python Discord Bot - 在调用函数时向特定频道发布消息
- macos - 在 macOS 中无法启动 Leap Motion Home 应用程序