Skip to content

Commit

Permalink
Make API routes optional
Browse files Browse the repository at this point in the history
  • Loading branch information
shianqi committed Jan 2, 2020
1 parent d55b464 commit afae040
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const defaultConfig: { [key: string]: any } = {
reactMode: 'legacy',
workerThreads: false,
basePath: '',
useApiRoutes: true,
},
future: {
excludeDefaultMomentLocales: false,
Expand Down
8 changes: 7 additions & 1 deletion packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,13 @@ export default class Server {
}
}

if (params && params.path && params.path[0] === 'api') {
if (
this.nextConfig.experimental &&
this.nextConfig.experimental.useApiRoutes &&
params &&
params.path &&
params.path[0] === 'api'
) {
const handled = await this.handleApiRequest(
req as NextApiRequest,
res as NextApiResponse,
Expand Down

0 comments on commit afae040

Please sign in to comment.