I was making a client .setEndpoint('https://cloud.appwrite.io/v1') and its not working showing this on clicking this link Error 404 The requested route was not found. Please refer to the API docs and try again. And while open the localhost/3000 getting this error Unhandled Runtime Error
AppwriteException: Network request failed Call Stack AppwriteException node_modules\appwrite\dist\esm\sdk.js (82:0) call/< node_modules\appwrite\dist\esm\sdk.js (404:0) rejected node_modules\appwrite\dist\esm\sdk.js (23:41)
Can you show your entire code?
There are chances that the endpoints weren't set properly
import { Client,Account,ID,Databases,Storage } from "appwrite";
const client = new Client(); client .setEndpoint('https://cloud.appwrite.io/v1') .setProject('process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID');
const account = new Account(client) const databases = new Databases(client) const storage = new Storage(client)
export {client,account,databases,storage,ID}
This is appwrite file
export const getTodosGroupByColumn= async () =>{ const data = await databases.listDocuments( process.env.NEXT_PUBLIC_DATABASE_ID!, process.env.NEXT_PUBLIC_COLLECTION_ID! ) const todos = data.documents
// try{
const columns = todos.reduce((acc,todo)=>{
if(!acc.get(todo.status)){
acc.set(todo.status,{
id: todo.status,
todos:[]
})
}
acc.get(todo.status)!.todos.push({
$id : todo.$id,
$createdAt:todo.$createdAt,
title: todo.title,
status:todo.status,
//get image if exists on the todo
...(todo.image && {image:JSON.parse(todo.image)})
})
return acc
},new Map<TypedColumn,Column>())
console.log(columns)
// }catch (e){
// console.error(e)
// }
}
What are you trying to do?
I made a database in appwrite and in that database there are todos in that there are mainly three main category according to those category things will filter out with the help of map
In chrome in console this is showing
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io/v1/databases/655248ee50900f83353c/collections/65524a5470af0aafb0e9/documents. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 404.
Uncaught (in promise) AppwriteException: Network request failed AppwriteException sdk.js:82 call sdk.js:404 rejected sdk.js:23
Here's a similar CORS related issue that has happened - https://stackoverflow.com/questions/76454243/appwrite-react-cross-origin-request-blocked#:~:text=CORS%20errors%20when%20working%20with,set%20correctly%20in%20the%20platform.
See if this can help
@Adnan Khan Are you self-hosting appwrite?
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...