-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build failed for adapter Cloudflare #132
Comments
Hi @Scorpio3310! // hooks.server.js
/** @type {import('@sveltejs/kit').Handle} */
export const handle = async ({ event, resolve }) => {
// ...
try {
// Fetch the redirected route
const response = await fetch(redirectTo, request);
// Get response body and set html headers
const data = await response.text();
// Serve the redirected route.
// In this case we don't have to set the html 'lang' attribute
// as the default locale is already included in our app.html.
return new Response(data, {
...response,
headers: {
...response.headers,
'Content-Type': isDataRequest ? 'application/json' : 'text/html',
},
});
} catch (error) {
// In case of error redirect to the error page.
return resolve({ ...event, locals: { lang: locale } }, {
transformPageChunk: ({ html }) => html.replace('%lang%', `${locale}`),
})
}
} |
@jarda-svoboda thank you it's working! 💯 Another question. I have set |
Well, because your So update |
Hi,
I wanted to build an app with the Cloudflare adapter. I used only this example (https://github.com/sveltekit-i18n/lib/tree/master/examples/locale-router-advanced) in my project, and when I try to build the app, the build fails.
Any ideas on how can I solve this?
Full code in attachment.
Using @sveltejs/adapter-cloudflare
node:internal/event_target:1006
process.nextTick(() => { throw err; });
^
Error: Could not create a fallback page — failed with status 500
at generate_fallback (file:///Users/nik/Sites/language-test/my-app/node_modules/@sveltejs/kit/src/core/postbuild/fallback.js:53:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async MessagePort. (file:///Users/nik/Sites/language-test/my-app/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
Emitted 'error' event on Worker instance at:
at [kOnErrorMessage] (node:internal/worker:290:10)
at [kOnMessage] (node:internal/worker:301:37)
at MessagePort. (node:internal/worker:202:57)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:731:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
Node.js v18.12.0
my-app.zip
The text was updated successfully, but these errors were encountered: