Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LN Address #96

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
if(process.env.BTCPAY_URL &&request.nextUrl.pathname.startsWith('/.well-known/lnurlp/')) {
//take process.env.BTCPAY_URL and strip the /api/v1/ from it, then take the username being requested and append it to the end
const lnAddressEndpoint = `${process.env.BTCPAY_URL.replace('/api/v1/', '')}/.well-known/lnurlp/${request.nextUrl.pathname.replace('/.well-known/lnurlp/', '')}`;
return NextResponse.rewrite(lnAddressEndpoint);
}
// you can even extend this and add nip5 support for each project on opensats, but that requires you to install the Nostr plugin on BTCPay
}
export const config = {
matcher: '/.well-known/:path+',
};
Loading