Working on a new social media app using appwrite and nextjs, encountering an error "TypeError: URL constructor: /account is not a valid URL" upon loading the website. Here's the current file structure of my app: File Structure
Below is the layout.tsx file from the main app directory:
import type { Metadata } from 'next'
import './globals.css'
import { QueryProvider } from './lib/queries/QueryProvider'
import AuthProvider from './context/AuthContext'
import { Toaster } from '@/components/ui/toaster'
export const metadata: Metadata = {
title: 'Janadh',
description: 'The Social Media of Education',
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<QueryProvider>
<AuthProvider>
{children}
<Toaster />
</AuthProvider>
</QueryProvider>
</body>
</html>
)
}
Here's the content of app/lib/appwrite/api.ts:
import { INewUser } from "@/app/types";
import { ID, Query } from "appwrite";
import { account, appwriteConfig, avatars, databases } from "./config";
export async function createUserAccount(user: INewUser) {
try {
const newAccount = await account.create(
ID.unique(),
user.email,
user.password,
user.name
);
if (!newAccount) throw Error;
const avatarUrl = avatars.getInitials(user.name);
const newUser = await saveUserToDB({
accountId: newAccount.$id,
name: newAccount.name,
email: newAccount.email,
username: user.username,
imageUrl: avatarUrl,
});
return newUser;
} catch (error) {
console.log(error);
}
}
// More functions and code here...
For additional code or assistance with resolving the error, feel free to reach out.