ShuYangOriginal post
Web Developer
Hello all, I'm currently working on implementing a Next.js API that sends emails with a magic URL. However, I'm running into a 404 error saying 'The requested route was not found. Please refer to the API docs and try again.' I don't know where I did wrong and need your help, thank you.
TypeScript
// src/app/api/magic-url/email/route.tsimport { createAdminClient } from '@/lib/appwrite/server'import { NextRequest } from 'next/server'import { ID } from 'node-appwrite'
export async function POST(req: NextRequest) { const { account } = await createAdminClient() const { email, url } = await req.json()
try { const token = await account.createMagicURLToken(ID.unique(), email, url) console.log('token', token) return Response.json({}) } catch (error) { return Response.json({ error }) }}Summary
Developers are encountering a 404 error while using node-appwrite `createMagicURLToken`. They are unsure if they need to set up anything on the Appwrite console. The code snippet provided shows an implementation of Next.js API for sending emails with a magic URL.
Possible solution:
- Make sure the app and Appwrite are on the same host.
- Verify the correctness of the route and ensure Appwrite is correctly set up to handle the request.