You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
Binaries:
Node: 16.13.2
npm: 8.1.2
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.5-canary.4
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome Version 107.0.5304.110
How are you deploying your application? (if relevant)
No response
Describe the Bug
I'm trying to make a user action trigger some server-side code run on serverless functions. When I import "server-only" to my serverless function (or any other server-only import), then call it from a client-side component, it throws an error saying the serverless function in the API directory is a child of my client component and is therefore client-side.
Expected Behavior
Serverless functions in the API directory should not be run client-side and should not throw an error when called through an API request from a client-side component.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
Start the application, then click the button labeled "Click Me".
To reproduce in a new project, just install "server-only", then import it to any serverless function in the api directory. Create a client-side component with "use client", a function that calls the serverless function using fetch, and a trigger within that component such as an onClick. Then, trigger the API call to view the error.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000
Binaries:
Node: 16.13.2
npm: 8.1.2
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.5-canary.4
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome Version 107.0.5304.110
How are you deploying your application? (if relevant)
No response
Describe the Bug
I'm trying to make a user action trigger some server-side code run on serverless functions. When I import "server-only" to my serverless function (or any other server-only import), then call it from a client-side component, it throws an error saying the serverless function in the API directory is a child of my client component and is therefore client-side.
Expected Behavior
Serverless functions in the API directory should not be run client-side and should not throw an error when called through an API request from a client-side component.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://github.com/gregfromstl/serverless-runs-client-side
To Reproduce
Start the application, then click the button labeled "Click Me".
To reproduce in a new project, just install "server-only", then import it to any serverless function in the
api
directory. Create a client-side component with"use client"
, a function that calls the serverless function usingfetch
, and a trigger within that component such as anonClick
. Then, trigger the API call to view the error.The text was updated successfully, but these errors were encountered: