Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
vicotor
frontend
Commits
cb603dd3
Commit
cb603dd3
authored
Dec 26, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prefix to proxy path
parent
ec77fa3d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
6 deletions
+6
-6
rewrites.js
configs/nextjs/rewrites.js
+1
-1
buildUrl.ts
lib/api/buildUrl.ts
+1
-1
proxy.ts
pages/api/proxy.ts
+1
-1
buildApiUrl.ts
playwright/utils/buildApiUrl.ts
+1
-1
ProfileMenuMobile.pw.tsx
ui/snippets/profileMenu/ProfileMenuMobile.pw.tsx
+2
-2
No files found.
configs/nextjs/rewrites.js
View file @
cb603dd3
async
function
rewrites
()
{
async
function
rewrites
()
{
return
[
return
[
{
source
:
'
/node-api/proxy/:slug*
'
,
destination
:
'
/api/proxy
'
},
{
source
:
'
/node-api/:slug*
'
,
destination
:
'
/api/:slug*
'
},
{
source
:
'
/node-api/:slug*
'
,
destination
:
'
/api/:slug*
'
},
{
source
:
'
/proxy/:slug*
'
,
destination
:
'
/api/proxy
'
},
].
filter
(
Boolean
);
].
filter
(
Boolean
);
}
}
...
...
lib/api/buildUrl.ts
View file @
cb603dd3
...
@@ -24,7 +24,7 @@ export default function buildUrl(
...
@@ -24,7 +24,7 @@ export default function buildUrl(
const
baseUrl
=
needProxy
?
appConfig
.
baseUrl
:
(
resource
.
endpoint
||
appConfig
.
api
.
endpoint
);
const
baseUrl
=
needProxy
?
appConfig
.
baseUrl
:
(
resource
.
endpoint
||
appConfig
.
api
.
endpoint
);
const
basePath
=
resource
.
basePath
!==
undefined
?
resource
.
basePath
:
appConfig
.
api
.
basePath
;
const
basePath
=
resource
.
basePath
!==
undefined
?
resource
.
basePath
:
appConfig
.
api
.
basePath
;
const
path
=
needProxy
?
'
/proxy
'
+
basePath
+
resource
.
path
:
basePath
+
resource
.
path
;
const
path
=
needProxy
?
'
/
node-api/
proxy
'
+
basePath
+
resource
.
path
:
basePath
+
resource
.
path
;
const
url
=
new
URL
(
compile
(
path
)(
pathParams
),
baseUrl
);
const
url
=
new
URL
(
compile
(
path
)(
pathParams
),
baseUrl
);
queryParams
&&
Object
.
entries
(
queryParams
).
forEach
(([
key
,
value
])
=>
{
queryParams
&&
Object
.
entries
(
queryParams
).
forEach
(([
key
,
value
])
=>
{
...
...
pages/api/proxy.ts
View file @
cb603dd3
...
@@ -11,7 +11,7 @@ const handler = async(_req: NextApiRequest, res: NextApiResponse) => {
...
@@ -11,7 +11,7 @@ const handler = async(_req: NextApiRequest, res: NextApiResponse) => {
}
}
const
response
=
await
fetchFactory
(
_req
,
_req
.
headers
[
'
x-endpoint
'
]?.
toString
())(
const
response
=
await
fetchFactory
(
_req
,
_req
.
headers
[
'
x-endpoint
'
]?.
toString
())(
_req
.
url
.
replace
(
/^
\/
proxy/
,
''
),
_req
.
url
.
replace
(
/^
\/
node-api
\/
proxy/
,
''
),
_pickBy
(
_pick
(
_req
,
[
'
body
'
,
'
method
'
]),
Boolean
),
_pickBy
(
_pick
(
_req
,
[
'
body
'
,
'
method
'
]),
Boolean
),
);
);
...
...
playwright/utils/buildApiUrl.ts
View file @
cb603dd3
...
@@ -5,5 +5,5 @@ import { RESOURCES } from 'lib/api/resources';
...
@@ -5,5 +5,5 @@ import { RESOURCES } from 'lib/api/resources';
export
default
function
buildApiUrl
(
resourceName
:
ResourceName
,
pathParams
?:
Record
<
string
,
string
>
)
{
export
default
function
buildApiUrl
(
resourceName
:
ResourceName
,
pathParams
?:
Record
<
string
,
string
>
)
{
const
resource
=
RESOURCES
[
resourceName
];
const
resource
=
RESOURCES
[
resourceName
];
return
compile
(
'
/proxy/poa/core
'
+
resource
.
path
)(
pathParams
);
return
compile
(
'
/
node-api/
proxy/poa/core
'
+
resource
.
path
)(
pathParams
);
}
}
ui/snippets/profileMenu/ProfileMenuMobile.pw.tsx
View file @
cb603dd3
import
{
test
,
expect
,
devices
}
from
'
@playwright/experimental-ct-react
'
;
import
{
test
,
expect
,
devices
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
RESOURCES
}
from
'
lib/api/resources
'
;
import
*
as
profileMock
from
'
mocks/user/profile
'
;
import
*
as
profileMock
from
'
mocks/user/profile
'
;
import
authFixture
from
'
playwright/fixtures/auth
'
;
import
authFixture
from
'
playwright/fixtures/auth
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
buildApiUrl
from
'
playwright/utils/buildApiUrl
'
;
import
ProfileMenuMobile
from
'
./ProfileMenuMobile
'
;
import
ProfileMenuMobile
from
'
./ProfileMenuMobile
'
;
...
@@ -30,7 +30,7 @@ test.describe('auth', () => {
...
@@ -30,7 +30,7 @@ test.describe('auth', () => {
});
});
extendedTest
(
'
base view
'
,
async
({
mount
,
page
})
=>
{
extendedTest
(
'
base view
'
,
async
({
mount
,
page
})
=>
{
await
page
.
route
(
'
/proxy/poa/core
'
+
RESOURCES
.
user_info
.
path
,
(
route
)
=>
route
.
fulfill
({
await
page
.
route
(
buildApiUrl
(
'
user_info
'
)
,
(
route
)
=>
route
.
fulfill
({
status
:
200
,
status
:
200
,
body
:
JSON
.
stringify
(
profileMock
.
base
),
body
:
JSON
.
stringify
(
profileMock
.
base
),
}));
}));
...
...
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