Unverified Commit e8ae4e21 authored by Damien Simonin Feugas's avatar Damien Simonin Feugas Committed by GitHub

fix(#44077): allow edge runtime for api routes inside src/ folder (#45093)

fixes: https://github.com/vercel/next.js/issues/44382
closes: https://github.com/vercel/next.js/pull/44882
closes: https://github.com/vercel/next.js/pull/44383
parent 9db81458
......@@ -332,7 +332,7 @@ export async function getPageStaticInfo(params: {
const requiresServerRuntime = ssr || ssg || pageType === 'app'
const isAnAPIRoute = isAPIRoute(page?.replace(/^\/pages\//, '/'))
const isAnAPIRoute = isAPIRoute(page?.replace(/^(?:\/src)?\/pages\//, '/'))
resolvedRuntime = isEdgeRuntime(resolvedRuntime)
? resolvedRuntime
......
export default () => new Response('ok')
export const config = { runtime: 'edge' }
......@@ -4,14 +4,16 @@ import { fetchViaHTTP, File, nextBuild } from 'next-test-utils'
import { join } from 'path'
import stripAnsi from 'strip-ansi'
const appDir = join(__dirname, './app')
const pagePath = 'pages/index.jsx'
const apiPath = 'pages/api/edge.js'
const page = new File(join(appDir, pagePath))
const api = new File(join(appDir, apiPath))
describe('Configurable runtime for pages and API routes', () => {
describe.each([
{ appDir: join(__dirname, './app/src'), title: 'src/pages and API routes' },
{ appDir: join(__dirname, './app'), title: 'pages and API routes' },
])('Configurable runtime for $title', ({ appDir }) => {
let next: NextInstance
const page = new File(join(appDir, pagePath))
const api = new File(join(appDir, apiPath))
if ((global as any).isNextDev) {
describe('In dev mode', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment