【发布时间】:2020-04-21 02:33:21
【问题描述】:
我希望能够创建自定义路径。例如,如果用户单击按钮 [创建房间],浏览器会将用户重定向到:http://www.example.com/[room_id]/index.html
有没有办法实现这个?用户将提交一个带有按钮的表单。类似的东西。
基本上这就是我所拥有的
index.html
<form method='POST' name='path_id' id='clickedButtom'>
<input id="pickName" class="center-align" type='text'>
<input id='rea2dy' value=" Ready >" type='submit'>
</form>
server.js
app.get('path_id', function(req, res) {
res.send('hello');
});
//I was the path_id to be a random string of letters and numbers basically
【问题讨论】:
-
如果有后端服务器处理表单,可以通过将用户重定向到您想要的 URL 来完成
-
我不确定我是否理解,我更新了问题以提供更多见解
-
我的意思是在后端你可以做
res.redirect('http://your.site/custom/path') -
我明白了,这是有道理的。谢谢你:)
标签: node.js express socket.io routes