Skip to content

Commit bbccdf7

Browse files
committed
feat: verify no netlify forms
1 parent 7e2b9e1 commit bbccdf7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/build/content/prerendered.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
NetlifyIncrementalCacheValue,
1919
} from '../../shared/cache-types.cjs'
2020
import type { PluginContext } from '../plugin-context.js'
21+
import { verifyNoNetlifyForms } from '../verification.js'
2122

2223
const tracer = wrapTracer(trace.getTracer('Next runtime'))
2324

@@ -169,6 +170,11 @@ export const copyPrerenderedContent = async (ctx: PluginContext): Promise<void>
169170
throw new Error(`Unrecognized content: ${route}`)
170171
}
171172

173+
// Netlify Forms are not support and require a workaround
174+
if (value.kind === 'PAGE') {
175+
verifyNoNetlifyForms(ctx, value.html)
176+
}
177+
172178
await writeCacheEntry(key, value, lastModified, ctx)
173179
}),
174180
),

src/build/verification.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ export async function verifyNoAdvancedAPIRoutes(ctx: PluginContext) {
8585
)
8686
}
8787
}
88+
89+
export function verifyNoNetlifyForms(ctx: PluginContext, html: string) {
90+
if (/<form[^>]*?\s(netlify|data-netlify)[=>\s]/.test(html)) {
91+
ctx.failBuild(
92+
`@netlify/plugin-next@5 does not support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example.`,
93+
)
94+
}
95+
}

0 commit comments

Comments
 (0)