Skip to content

Commit 06e08c3

Browse files
committed
adjust middleware
1 parent 75197da commit 06e08c3

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### MultiversX devnet faucet (distribution) smart contract
22

33
- The frontent Dapp for the [MultiversX ESDT Faucet Smart Contract](https://github.com/xdevguild/esdt-faucet-sc).
4-
- Based on the [MultiversX Nextjs Dapp Template](https://github.com/xdevguild/nextjs-dapp-template).
4+
- Based on the older version of [MultiversX Nextjs Dapp Template](https://github.com/xdevguild/nextjs-dapp-template).
55
- Live app on the devnet: [https://devnet-multiversx-esdt-faucet.netlify.app](https://devnet-multiversx-esdt-faucet.netlify.app/)
66
- Walkthrough video: [https://youtu.be/yBvtM2ZqJGk](https://youtu.be/yBvtM2ZqJGk)
77

middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface CustomNextRequest extends NextRequest {
1515
export function middleware(req: CustomNextRequest) {
1616
const res = NextResponse.next();
1717

18-
if (!process.env.NEXT_PUBLIC_MULTIVERSX_API) return res;
18+
if (!process.env.NEXT_PUBLIC_MULTIVERSX_API?.includes('/api')) return res;
1919

2020
if (req.nextUrl.pathname.startsWith(process.env.NEXT_PUBLIC_MULTIVERSX_API)) {
2121
const definedHost = process.env.API_ALLOWED_DAPP_HOST;

next.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ const nextConfig = {
1414
},
1515
reactStrictMode: true,
1616
async rewrites() {
17+
if (!process.env.MULTIVERSX_PRIVATE_API) {
18+
return [];
19+
}
1720
return [
1821
{
1922
source: `${process.env.NEXT_PUBLIC_MULTIVERSX_API}/:path*`,
2023
destination: `${process.env.MULTIVERSX_CUSTOM_API}/:path*`,
24+
destination: `${process.env.MULTIVERSX_PRIVATE_API}/:path*`,
2125
},
2226
];
2327
},

0 commit comments

Comments
 (0)