web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

[bug] 404 error on domain verification /.well-known/walletconnect.txt

Open hroyo opened this issue 1 year ago • 4 comments

Link to minimal reproducible example

go to could.walletconnect.com verify domain with txt

Summary

Deep linking on mobile is not prompting signature in the wallet and not returning to the website. Is it caused by domain allowlist issue? It is on a staging on vercel it is impossible to verify it because links sends to 404 error.

Could you send me a txt file so I can verify the vercel deployement?

List of related npm package versions

web3modal

"viem": "^2.9.16",
"wagmi": "^2.5.19",
"@web3modal/wagmi": "^5.0.2",

hroyo avatar Aug 20 '24 07:08 hroyo

How many issues are you posting ? please split in different issues for different problems. This issue will be the 404 for txt verification.

https://linear.app/walletconnect/issue/CLO-171/[bug]-well-knownwalletconnecttxt-return-404

rtomas avatar Aug 22 '24 03:08 rtomas

@hroyo you can serve the .txt on vercel as needed for domain verification. you can take advantage of rewrites and return a text/plain response from your api. This was my solution:

app/.well-known/walletconnect.txt - contains the required text for verification

/api/walletconnect/route.ts

'use server';
import fs from 'fs';
import { NextRequest } from 'next/server';
import path from 'path';

export async function GET(req: NextRequest) {
  const filePath = path.join(
    process.cwd(),
    'app/.well-known/walletconnect.txt',
  );
  const fileContents = fs.readFileSync(filePath, 'utf8');

  return new Response(fileContents, {
    headers: {
      'Content-Type': 'text/plain',
    },
  });
}

next.config.mjs

...
async rewrites() {
    return [
      {
        source: '/.well-known/walletconnect.txt',
        destination: '/api/walletconnect',
      },
    ];
  },
....

with these changes in place you'll be able to serve the .txt file: `hxxps://**.vercel.app/.well-known/walletconnect.txt

andrewrexo avatar Aug 26 '24 16:08 andrewrexo

the route version gave me a Error: ENOENT: no such file or directory

I can place the /.well-known/walletconnect.txt in the public folder instead of app?

hroyo avatar Aug 26 '24 17:08 hroyo

this is solved thank you

hroyo avatar Aug 27 '24 17:08 hroyo