Skip to content

Impossible to set a cookie on route.ts #74326

Closed Answered by AnouarMc
NatigAgarzayev asked this question in Help
Discussion options

You must be logged in to vote

I tested your repo, and it works fine. You just need to remove 'use server' from the handleSignUp method and make the signup page a client component.

"use client";

import React from "react";

export default function page() {
  const handleSignUp = async (formData: FormData) => {
    const name = formData.get("name") as string;
    const email = formData.get("email") as string;
    const password = formData.get("password") as string;

    if (!name || !email || !password) {
      return;
    }

    const res = await fetch("http://localhost:3000/api/user/signup", {
      method: "POST",
      body: JSON.stringify({
        name,
        email,
        password,
      }),
    });

    console.

Replies: 6 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@NatigAgarzayev
Comment options

@dev-kraken
Comment options

Comment options

You must be logged in to vote
1 reply
@NatigAgarzayev
Comment options

Comment options

You must be logged in to vote
1 reply
@NatigAgarzayev
Comment options

Comment options

You must be logged in to vote
1 reply
@NatigAgarzayev
Comment options

Answer selected by NatigAgarzayev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Issue was opened via the bug report template. Documentation Related to Next.js' official documentation. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes.
5 participants
Converted from issue

This discussion was converted from issue #74298 on December 27, 2024 16:34.