Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge API routes exclude src directory #44077

Closed
1 task done
nickbabcock opened this issue Dec 16, 2022 · 6 comments · Fixed by #45093
Closed
1 task done

Edge API routes exclude src directory #44077

nickbabcock opened this issue Dec 16, 2022 · 6 comments · Fixed by #45093
Labels
bug Issue was opened via the bug report template.

Comments

@nickbabcock
Copy link
Contributor

nickbabcock commented Dec 16, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022
Binaries:
  Node: 18.12.1
  npm: 8.19.2
  Yarn: 1.22.19
  pnpm: 7.17.1
Relevant packages:
  next: 13.0.7
  eslint-config-next: 13.0.7
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

https://github.com/nickbabcock/rl-web

To Reproduce

Switch config of src/pages/api/replay to:

export const config = {
  runtime: "edge",
};

And execute npm run dev.

(apologies, the repo isn't technically a minimal reproduction (as 13.0.7, seems to break in other ways), but the issue / solution should be clear. If not I'll create one a minimal reproduction).

Describe the Bug

Next.js supports putting pages in the src directory.

So when I tried testing GA version of edge functions (#44045 cc @feugy), I received the following error:

Page /src/pages/api/replay provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.

I see that #44045 looks if the route starts with /pages so a /src/pages route throws it off. The solution seems like it should look in the src directory too.

A temporary workaround is to move the pages outside of the src directory.

Expected Behavior

If src directory is supported then edge API routes hosted in src/pages/api shouldn't error.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@nickbabcock nickbabcock added the bug Issue was opened via the bug report template. label Dec 16, 2022
@controversial
Copy link

Here’s a minimal reproduction: https://github.com/controversial/nextjs-edge-functions-ga-error-repro

In the commit history, you can see that the penultimate commit (git checkout HEAD~1) works, while the most recent commit (which just moves pagessrc/pages; git checkout main) fails.

Note that this error still exists in the 13.1 release, as well as in the 13.1.1-canary.0.

The 13.1 release notes advertise that

"experimental-" prefix is no longer needed

but this isn’t true if a project uses a src folder.

@controversial
Copy link

This screenshot shows the issue clearly:

Screenshot 2022-12-23 at 5 03 03 PM

@ijjk
Copy link
Member

ijjk commented Jan 20, 2023

Hi, this has been updated in v13.1.4-canary.1 of Next.js, please update and give it a try!

@feugy
Copy link
Member

feugy commented Jan 23, 2023

Thanks for the bug report @controversial, and apologies for the lag. Let us know if you have other related blockers!

@controversial
Copy link

Thanks for getting on this @feugy! The main other related (as far as edge API routes) blocker for me is #38302

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants