Closed
Description
Summary
When deploying my project, I get "Could not find source file for pages" errors for my routes. I believe this is because my routes are defined as index files in the named folder within the api folder (i.e. /api/analyze/index.api.ts
).
The plugin is looking for the file at /api/analyze.api.ts
and doesn't seem to be considering that it could be an index file within a folder of that route's name.
Steps to reproduce
- Create a Next.JS project that has an api handler located in /api/test/index.ts
- Deploy and check the build logs
A link to a reproduction repository
No response
Next Runtime version
4.36.1
Is your issue related to the app
directory (beta)?
- Yes, I am using the
app
directory
More information about your build
- I am building using the CLI
- I am building using file-based configuration (
netlify.toml
)
What OS are you using?
None
Your netlify.toml file
No response
Your public/_redirects file
No response
Your next.config.js
file
`next.config.js`
/** @type {import('next').NextConfig} */
/* eslint-disable @typescript-eslint/no-var-requires */
const { withSentryConfig } = require('@sentry/nextjs');
const withRoutes = require('nextjs-routes/config')({
outDir: 'src/types',
});
const securityHeaders = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
];
const nextConfig = {
pageExtensions: ['page.tsx', 'api.ts'],
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/:path*',
headers: securityHeaders,
},
];
},
sentry: {
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
// for client-side builds. (This will be the default starting in
// `@sentry/nextjs` version 8.0.0.) See
// https://webpack.js.org/configuration/devtool/ and
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
// for more information.
hideSourceMaps: true,
},
};
module.exports = async () => {
/**
* @type {import('next').NextConfig}
*/
const plugins = [
withRoutes,
(config) =>
withSentryConfig(config, {
silent: true,
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
}),
];
return plugins.reduce((acc, next) => next(acc), nextConfig);
};
Builds logs (or link to your logs)
Function logs
No response
.next JSON files
No response