Skip to content

Commit

Permalink
adjust middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Nov 1, 2023
1 parent 75197da commit 06e08c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### MultiversX devnet faucet (distribution) smart contract

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

Expand Down
2 changes: 1 addition & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface CustomNextRequest extends NextRequest {
export function middleware(req: CustomNextRequest) {
const res = NextResponse.next();

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

if (req.nextUrl.pathname.startsWith(process.env.NEXT_PUBLIC_MULTIVERSX_API)) {
const definedHost = process.env.API_ALLOWED_DAPP_HOST;
Expand Down
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ const nextConfig = {
},
reactStrictMode: true,
async rewrites() {
if (!process.env.MULTIVERSX_PRIVATE_API) {
return [];
}
return [
{
source: `${process.env.NEXT_PUBLIC_MULTIVERSX_API}/:path*`,
destination: `${process.env.MULTIVERSX_CUSTOM_API}/:path*`,
destination: `${process.env.MULTIVERSX_PRIVATE_API}/:path*`,
},
];
},
Expand Down

0 comments on commit 06e08c3

Please sign in to comment.