Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8a8202ae
authored
Sep 18, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: enable cors for token routers and dashboard routers
parent
8344b66b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
controller/relay-text.go
+1
-1
router/api-router.go
+6
-1
router/dashboard.go
+1
-0
No files found.
controller/relay-text.go
View file @
8a8202ae
...
@@ -212,7 +212,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
...
@@ -212,7 +212,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
// in this case, we do not pre-consume quota
// in this case, we do not pre-consume quota
// because the user has enough quota
// because the user has enough quota
preConsumedQuota
=
0
preConsumedQuota
=
0
common
.
LogInfo
(
c
.
Request
.
Context
(),
fmt
.
Sprintf
(
"user %d has enough quota %d, trusted and no need to pre-consume"
,
userId
,
userQuota
))
//
common.LogInfo(c.Request.Context(), fmt.Sprintf("user %d has enough quota %d, trusted and no need to pre-consume", userId, userQuota))
}
}
if
consumeQuota
&&
preConsumedQuota
>
0
{
if
consumeQuota
&&
preConsumedQuota
>
0
{
err
:=
model
.
PreConsumeTokenQuota
(
tokenId
,
preConsumedQuota
)
err
:=
model
.
PreConsumeTokenQuota
(
tokenId
,
preConsumedQuota
)
...
...
router/api-router.go
View file @
8a8202ae
...
@@ -109,7 +109,12 @@ func SetApiRouter(router *gin.Engine) {
...
@@ -109,7 +109,12 @@ func SetApiRouter(router *gin.Engine) {
logRoute
.
GET
(
"/search"
,
middleware
.
AdminAuth
(),
controller
.
SearchAllLogs
)
logRoute
.
GET
(
"/search"
,
middleware
.
AdminAuth
(),
controller
.
SearchAllLogs
)
logRoute
.
GET
(
"/self"
,
middleware
.
UserAuth
(),
controller
.
GetUserLogs
)
logRoute
.
GET
(
"/self"
,
middleware
.
UserAuth
(),
controller
.
GetUserLogs
)
logRoute
.
GET
(
"/self/search"
,
middleware
.
UserAuth
(),
controller
.
SearchUserLogs
)
logRoute
.
GET
(
"/self/search"
,
middleware
.
UserAuth
(),
controller
.
SearchUserLogs
)
logRoute
.
GET
(
"/token"
,
controller
.
GetLogByKey
)
logRoute
.
Use
(
middleware
.
CORS
())
{
logRoute
.
GET
(
"/token"
,
controller
.
GetLogByKey
)
}
groupRoute
:=
apiRouter
.
Group
(
"/group"
)
groupRoute
:=
apiRouter
.
Group
(
"/group"
)
groupRoute
.
Use
(
middleware
.
AdminAuth
())
groupRoute
.
Use
(
middleware
.
AdminAuth
())
{
{
...
...
router/dashboard.go
View file @
8a8202ae
...
@@ -11,6 +11,7 @@ func SetDashboardRouter(router *gin.Engine) {
...
@@ -11,6 +11,7 @@ func SetDashboardRouter(router *gin.Engine) {
apiRouter
:=
router
.
Group
(
"/"
)
apiRouter
:=
router
.
Group
(
"/"
)
apiRouter
.
Use
(
gzip
.
Gzip
(
gzip
.
DefaultCompression
))
apiRouter
.
Use
(
gzip
.
Gzip
(
gzip
.
DefaultCompression
))
apiRouter
.
Use
(
middleware
.
GlobalAPIRateLimit
())
apiRouter
.
Use
(
middleware
.
GlobalAPIRateLimit
())
apiRouter
.
Use
(
middleware
.
CORS
())
apiRouter
.
Use
(
middleware
.
TokenAuth
())
apiRouter
.
Use
(
middleware
.
TokenAuth
())
{
{
apiRouter
.
GET
(
"/dashboard/billing/subscription"
,
controller
.
GetSubscription
)
apiRouter
.
GET
(
"/dashboard/billing/subscription"
,
controller
.
GetSubscription
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment