I'm encountering an issue with my next.js app that utilizes server side rendering. Upon running the application locally and in production (on vercel edge), the initial page response seems to be a javascript bundle rather than the fully rendered HTML page. As a result, all the SEO efforts I've put in, such as defining <meta/>
tags, are essentially useless, since the first response lacks these tags. While the page loads correctly in the browser, it appears that web scrapers only consider the initial server response.
When inspecting the network tab, the first response with the "document" initiator reveals the following:
<!DOCTYPE html>
<html>
<head>
<style data-next-hide-fouc="true">
body {
display: none
}
</style><noscript data-next-hide-fouc="true">
<style>
body {
display: block
}
</style>
</noscript>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta name="next-head-count" content="2" /><noscript data-n-css=""></noscript>
<script defer="" nomodule="" src="/_next/static/chunks/polyfills.js?ts=1665897162450"></script>
... (truncated for brevity)
</html>
I initially believed that next.js would generate full HTML pages on the server before sending them to the browser. I'm uncertain whether configuring a "production" build option within the next.config.js
file could resolve this, or if it's a bug within next.js itself.
Below is an excerpt from my _app.js file:
import React from 'react';
... (code continues, truncated for brevity)
I would greatly appreciate any assistance or insights on this matter!