Skip to content

Commit

Permalink
Support LN Address
Browse files Browse the repository at this point in the history
This PR adds support for lightning addresses directly through the opensats website and all functioanlity is handled on the btcpay side, if the LN address is configured as described in OpenSats#8 (comment)
  • Loading branch information
Kukks committed May 5, 2023
1 parent a3cf9c3 commit 92d3b6a
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 143 deletions.
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

0 comments on commit 92d3b6a

Please sign in to comment.