Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
71850e31
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
71850e31
编写于
11月 10, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid setting ?to=/
That's the default so it's extra visual noise.
上级
b8340a2a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
5 deletion
+7
-5
src/node/routes/domainProxy.ts
src/node/routes/domainProxy.ts
+1
-1
src/node/routes/pathProxy.ts
src/node/routes/pathProxy.ts
+4
-3
src/node/routes/vscode.ts
src/node/routes/vscode.ts
+2
-1
未找到文件。
src/node/routes/domainProxy.ts
浏览文件 @
71850e31
...
...
@@ -55,7 +55,7 @@ router.all("*", (req, res, next) => {
}
// Redirect all other pages to the login.
return
redirect
(
req
,
res
,
"
login
"
,
{
to
:
req
.
path
,
to
:
req
.
path
!==
"
/
"
?
req
.
path
:
undefined
,
})
}
...
...
src/node/routes/pathProxy.ts
浏览文件 @
71850e31
import
{
Request
,
Router
}
from
"
express
"
import
qs
from
"
qs
"
import
{
HttpCode
,
HttpError
}
from
"
../../common/http
"
import
{
normalize
}
from
"
../../common/util
"
import
{
authenticated
,
ensureAuthenticated
,
redirect
}
from
"
../http
"
import
{
proxy
}
from
"
../proxy
"
import
{
Router
as
WsRouter
}
from
"
../wsRouter
"
...
...
@@ -17,11 +18,11 @@ const getProxyTarget = (req: Request, rewrite: boolean): string => {
router
.
all
(
"
/(:port)(/*)?
"
,
(
req
,
res
)
=>
{
if
(
!
authenticated
(
req
))
{
// If visiting the root (/proxy/:port and nothing else) redirect to the
// login page.
// If visiting the root (/:port only) redirect to the login page.
if
(
!
req
.
params
[
0
]
||
req
.
params
[
0
]
===
"
/
"
)
{
const
to
=
normalize
(
`
${
req
.
baseUrl
}${
req
.
path
}
`
)
return
redirect
(
req
,
res
,
"
login
"
,
{
to
:
`
${
req
.
baseUrl
}${
req
.
path
}
`
||
"
/
"
,
to
:
to
!==
"
/
"
?
to
:
undefined
,
})
}
throw
new
HttpError
(
"
Unauthorized
"
,
HttpCode
.
Unauthorized
)
...
...
src/node/routes/vscode.ts
浏览文件 @
71850e31
...
...
@@ -15,7 +15,8 @@ const vscode = new VscodeProvider()
router
.
get
(
"
/
"
,
async
(
req
,
res
)
=>
{
if
(
!
authenticated
(
req
))
{
return
redirect
(
req
,
res
,
"
login
"
,
{
to
:
req
.
baseUrl
,
// req.baseUrl can be blank if already at the root.
to
:
req
.
baseUrl
&&
req
.
baseUrl
!==
"
/
"
?
req
.
baseUrl
:
undefined
,
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录