Skip to content

Commit

Permalink
Merge pull request #161 from SpeciesFileGroup/development
Browse files Browse the repository at this point in the history
Fix soft 404
  • Loading branch information
José Luis Pereira authored and GitHub committed Sep 27, 2023
2 parents 0bb213e + 3487afd commit 85006c4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/entry-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ import devalue from '@nuxt/devalue'

export async function render(url, manifest, originUrl) {
const { app, router, store } = createApp({ originUrl })
let statusCode = 200

// Register global components, create a fake server components for components that should only render on client side
registerGlobalComponents(app)
registerFakeClientComponents(app)

router.beforeEach((item) => {
const { meta } = item

if (meta?.statusCode) {
statusCode = meta.statusCode
}
})

// set the router to the desired URL before rendering
await router.push(url)
await router.isReady()
Expand All @@ -24,8 +33,8 @@ export async function render(url, manifest, originUrl) {
// components that have been instantiated during this render call.

const ctx = {}

const html = await renderToString(app, ctx)
const statusCode = router.currentRoute.value.meta?.statusCode || 200
const headPayload = await renderSSRHead(getActiveHead())
const renderState = `
<script>
Expand Down

0 comments on commit 85006c4

Please sign in to comment.