Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
15c90871
Commit
15c90871
authored
Feb 04, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update request base url
parent
be899cd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
server.go
server/server.go
+30
-0
grpcweb.ts
web/src/grpcweb.ts
+1
-1
api.ts
web/src/helpers/api.ts
+3
-0
No files found.
server/server.go
View file @
15c90871
...
...
@@ -62,6 +62,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
AllowMethods
:
[]
string
{
http
.
MethodGet
,
http
.
MethodHead
,
http
.
MethodPut
,
http
.
MethodPatch
,
http
.
MethodPost
,
http
.
MethodDelete
},
}))
e
.
Use
(
CORSMiddleware
())
e
.
Use
(
middleware
.
TimeoutWithConfig
(
middleware
.
TimeoutConfig
{
Skipper
:
timeoutSkipper
,
Timeout
:
30
*
time
.
Second
,
...
...
@@ -184,3 +186,31 @@ func timeoutSkipper(c echo.Context) bool {
// Skip timeout for blob upload which is frequently timed out.
return
c
.
Request
()
.
Method
==
http
.
MethodPost
&&
c
.
Request
()
.
URL
.
Path
==
"/api/v1/resource/blob"
}
func
CORSMiddleware
()
echo
.
MiddlewareFunc
{
return
func
(
next
echo
.
HandlerFunc
)
echo
.
HandlerFunc
{
return
func
(
c
echo
.
Context
)
error
{
if
grpcRequestSkipper
(
c
)
{
return
next
(
c
)
}
r
:=
c
.
Request
()
w
:=
c
.
Response
()
.
Writer
w
.
Header
()
.
Set
(
"Access-Control-Allow-Origin"
,
r
.
Header
.
Get
(
"Origin"
))
w
.
Header
()
.
Set
(
"Access-Control-Allow-Methods"
,
"GET, POST, PUT, DELETE, OPTIONS"
)
w
.
Header
()
.
Set
(
"Access-Control-Allow-Headers"
,
"Content-Type, Authorization"
)
w
.
Header
()
.
Set
(
"Access-Control-Allow-Credentials"
,
"true"
)
// If it's preflight request, return immediately.
if
r
.
Method
==
"OPTIONS"
{
w
.
WriteHeader
(
http
.
StatusOK
)
return
nil
}
// Continue processing request.
next
(
c
)
return
nil
}
}
}
web/src/grpcweb.ts
View file @
15c90871
...
...
@@ -10,7 +10,7 @@ import { WebhookServiceDefinition } from "./types/proto/api/v2/webhook_service";
import
{
WorkspaceServiceDefinition
}
from
"./types/proto/api/v2/workspace_service"
;
const
channel
=
createChannel
(
window
.
location
.
origin
,
import
.
meta
.
env
.
VITE_API_BASE_URL
||
window
.
location
.
origin
,
FetchTransport
({
credentials
:
"include"
,
}),
...
...
web/src/helpers/api.ts
View file @
15c90871
import
axios
from
"axios"
;
import
{
Resource
}
from
"@/types/proto/api/v2/resource_service"
;
axios
.
defaults
.
baseURL
=
import
.
meta
.
env
.
VITE_API_BASE_URL
||
window
.
location
.
origin
;
axios
.
defaults
.
withCredentials
=
true
;
export
function
getSystemStatus
()
{
return
axios
.
get
<
SystemStatus
>
(
"/api/v1/status"
);
}
...
...
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