Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
HasuraNodeComponent
Commits
217993b3
Unverified
Commit
217993b3
authored
1 year ago
by
Shishir Suman
Committed by
GitHub
1 year ago
Browse files
Options
Download
Patches
Plain Diff
adding logs
parent
a1c75662
UAT
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.js
+4
-0
index.js
with
4 additions
and
0 deletions
+4
-0
index.js
+
4
−
0
View file @
217993b3
...
@@ -30,6 +30,8 @@ const targetURL = process.env.TARGET_URL ;
...
@@ -30,6 +30,8 @@ const targetURL = process.env.TARGET_URL ;
const
hasuraClientName
=
process
.
env
.
HASURA_CLIENT_NAME
;
const
hasuraClientName
=
process
.
env
.
HASURA_CLIENT_NAME
;
const
hasuraAdminSecret
=
process
.
env
.
HASURA_ADMIN_SECRET
;
const
hasuraAdminSecret
=
process
.
env
.
HASURA_ADMIN_SECRET
;
const
REACT_APP_NODE_URL
=
process
.
env
.
REACT_APP_API_URL
;
const
REACT_APP_NODE_URL
=
process
.
env
.
REACT_APP_API_URL
;
console
.
log
(
"
hasuraClientName:
"
,
hasuraClientName
);
console
.
log
(
"
hasuraAdminSecret:
"
,
hasuraAdminSecret
);
// Creating an Axios instance with custom headers
// Creating an Axios instance with custom headers
const
axiosInstance
=
axios
.
create
({
const
axiosInstance
=
axios
.
create
({
...
@@ -53,6 +55,7 @@ endpoints.forEach((endpoint) => {
...
@@ -53,6 +55,7 @@ endpoints.forEach((endpoint) => {
proxyReq
.
setHeader
(
"
Hasura-Client-Name
"
,
hasuraClientName
);
proxyReq
.
setHeader
(
"
Hasura-Client-Name
"
,
hasuraClientName
);
if
(
endpoint
.
requestBody
)
{
if
(
endpoint
.
requestBody
)
{
const
bodyData
=
JSON
.
stringify
(
req
.
body
);
const
bodyData
=
JSON
.
stringify
(
req
.
body
);
console
.
log
(
"
Request body:
"
,
bodyData
);
proxyReq
.
setHeader
(
"
Content-Length
"
,
Buffer
.
byteLength
(
bodyData
));
proxyReq
.
setHeader
(
"
Content-Length
"
,
Buffer
.
byteLength
(
bodyData
));
}
}
// Set request body if provided
// Set request body if provided
...
@@ -62,6 +65,7 @@ endpoints.forEach((endpoint) => {
...
@@ -62,6 +65,7 @@ endpoints.forEach((endpoint) => {
proxyReq
.
end
();
proxyReq
.
end
();
},
},
onError
:
(
err
,
req
,
res
)
=>
{
onError
:
(
err
,
req
,
res
)
=>
{
console
.
log
(
"
res body:
"
,
res
);
// Handle errors from the upstream server
// Handle errors from the upstream server
console
.
error
(
"
Proxy Error:
"
,
err
.
message
);
console
.
error
(
"
Proxy Error:
"
,
err
.
message
);
res
.
status
(
500
).
send
(
"
Proxy Error:
"
+
err
.
message
);
res
.
status
(
500
).
send
(
"
Proxy Error:
"
+
err
.
message
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets