Problem with fetch /api/register getting the error http://localhost:3000/api/register 404 (Not Found)

I have tried everything I am just confused about what I am doing wrong because I redid all of the code completely and still ran into the error. Is there more that I have to do for fetch besides making a file directory to /api/register?

I’m new to posting questions on stack so it’s not letting me put my code here but I am free to answer any questions because I am so lost.

"use client";
import {signIn} from "next-auth/react";
import Image from "next/image";
import Link from "next/link";
import {useState} from "react";

export default function RegisterPage() {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [creatingUser, setCreatingUser] = useState(false);
  const [userCreated, setUserCreated] = useState(false);
  const [error, setError] = useState(false);
  async function handleFormSubmit(ev) {
    ev.preventDefault();
    setCreatingUser(true);
    setError(false);
    setUserCreated(false);
    const response = await fetch('/src/api/register', { 
      method: 'POST',
      body: JSON.stringify({email, password}),
      headers: {'Content-Type': 'application/json'},
    });
    if (response.ok) {
      setUserCreated(true);
    }
    else {
      setError(true);
    }
    setCreatingUser(false);
  }