Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
proxy-manager-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aolda
proxy-manager-frontend
Commits
f99d9645
Commit
f99d9645
authored
2 months ago
by
한동현
Browse files
Options
Downloads
Patches
Plain Diff
fix: API 요청시 토큰을 전달하지 않는 문제 수정
parent
5aecfa28
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pages/forwarding/Create.tsx
+2
-2
2 additions, 2 deletions
src/pages/forwarding/Create.tsx
src/pages/forwarding/List.tsx
+4
-4
4 additions, 4 deletions
src/pages/forwarding/List.tsx
src/stores/authStore.ts
+6
-0
6 additions, 0 deletions
src/stores/authStore.ts
with
12 additions
and
6 deletions
src/pages/forwarding/Create.tsx
+
2
−
2
View file @
f99d9645
...
...
@@ -25,7 +25,7 @@ const formSchema = z.object({
export
default
function
ForwardingCreate
()
{
const
navigate
=
useNavigate
();
const
{
selectedProject
}
=
useAuthStore
();
const
{
authFetch
,
selectedProject
}
=
useAuthStore
();
const
form
=
useForm
<
z
.
infer
<
typeof
formSchema
>>
({
resolver
:
zodResolver
(
formSchema
),
defaultValues
:
{
...
...
@@ -38,7 +38,7 @@ export default function ForwardingCreate() {
async
function
onSubmit
(
values
:
z
.
infer
<
typeof
formSchema
>
)
{
const
{
name
,
serverPort
,
instanceIp
}
=
values
;
const
response
=
await
f
etch
(
`/api/forwarding?projectId=
${
selectedProject
?.
id
}
`
,
{
const
response
=
await
authF
etch
(
`/api/forwarding?projectId=
${
selectedProject
?.
id
}
`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
...
...
This diff is collapsed.
Click to expand it.
src/pages/forwarding/List.tsx
+
4
−
4
View file @
f99d9645
...
...
@@ -22,12 +22,12 @@ import {
}
from
'
@/components/ui/alert-dialog
'
;
export
default
function
ForwardingList
()
{
const
{
selectedProject
}
=
useAuthStore
();
const
{
authFetch
,
selectedProject
}
=
useAuthStore
();
const
[
forwardings
,
setForwardings
]
=
useState
<
Forwarding
[]
|
null
>
(
null
);
const
[
selectedForwarding
,
setSelectedForwarding
]
=
useState
<
Forwarding
|
null
>
(
null
);
useEffect
(()
=>
{
f
etch
(
`/api/forwardings?projectId=
${
selectedProject
?.
id
}
`
)
authF
etch
(
`/api/forwardings?projectId=
${
selectedProject
?.
id
}
`
)
.
then
((
response
)
=>
{
if
(
!
response
.
ok
)
{
toast
.
error
(
'
포트포워딩 정보를 조회할 수 없습니다.
'
);
...
...
@@ -39,12 +39,12 @@ export default function ForwardingList() {
.
then
(({
contents
})
=>
{
setForwardings
(
contents
);
});
},
[
selectedProject
]);
},
[
authFetch
,
selectedProject
]);
const
handleDelete
=
()
=>
{
if
(
selectedForwarding
===
null
)
throw
Error
(
'
selectedForwarding is null
'
);
f
etch
(
`/api/forwarding?forwardingId=
${
selectedForwarding
.
id
}
`
,
{
authF
etch
(
`/api/forwarding?forwardingId=
${
selectedForwarding
.
id
}
`
,
{
method
:
'
DELETE
'
,
}).
then
((
response
)
=>
{
if
(
!
response
.
ok
)
{
...
...
This diff is collapsed.
Click to expand it.
src/stores/authStore.ts
+
6
−
0
View file @
f99d9645
...
...
@@ -9,6 +9,7 @@ export interface AuthStore {
projects
:
Project
[];
selectedProject
:
(
Project
&
{
role
?:
string
})
|
null
;
setSelectedProject
:
(
project
:
Project
)
=>
Promise
<
void
>
;
authFetch
:
(
input
:
RequestInfo
,
init
?:
RequestInit
)
=>
Promise
<
Response
>
;
login
:
(
username
:
string
,
password
:
string
)
=>
void
;
logout
:
()
=>
void
;
}
...
...
@@ -38,6 +39,11 @@ export const useAuthStore = create<AuthStore>()(
console
.
log
(
role
);
},
authFetch
:
async
(
input
,
init
)
=>
fetch
(
input
,
{
...
init
,
headers
:
{
...
init
?.
headers
,
'
X-Subject-Token
'
:
get
().
token
!
},
}),
login
:
async
(
username
,
password
)
=>
{
const
response
=
await
fetch
(
'
/api/auth/login
'
,
{
method
:
'
POST
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment