-
Hi there, recently I've deployed a svelte-kit app to cloudflare pages, however I'm facing an issue with a contact route. It uses actions to accept a post form submission and send an e-mail to my ticketing software. The server side code looks like this: // /src/routes/contact/+page.server.ts
export const actions = {
default: async ({ fetch, request }) => {
const data = await request.formData();
// fetch POST request to recaptcha to determine score
if (success && score >= 0.4) {
// send an e-mail to ticketing software with mailjet
return { success: true };
}
return { success: false };
}
} satisfies Actions; Then on the front-end it I'm using the results like this: // /src/routes/contact/+page.svelte
<script lang="ts">
import type { ActionData } from './$types';
// some imports, some variables
export let form: ActionData | null = null;
</script>
<!-- other markup -->
{#if form && form.success}
<!-- success alert -->
{:else if form && !form.success}
<!-- error alert -->
{/if} It works perfectly in the dev environment - with both
I'm honestly clueless - I've tried searching and found this stackoverflow question on It's like if my This is my import adapter from '@sveltejs/adapter-cloudflare';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { mdsvex } from 'mdsvex';
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [
vitePreprocess(),
mdsvex({
extensions: ['.md']
})
],
kit: {
adapter: adapter({
routes: {
include: ['/*'],
exclude: ['<all>']
}
}),
}
};
export default config; This is my only action in this project. I have some other server-side only endpoints - which work well. Same with other page-loads fetching data. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The logic in my actions doesn't matter. Even just returning |
Beta Was this translation helpful? Give feedback.
-
As mentioned by @s3812497 - if you're hitting similar errors on cloudflare-pages only, double check your dependencies for compatibility with cloudflare workers. |
Beta Was this translation helpful? Give feedback.
-
Hi , I faced a similar issue with actions on cloudflare. Couldn't find any helpful errors showing up anywhere. I found this thread and then figured out I should get rid of actions and use cloudflare workers instead. My sveltekit application needed an action to airtable and thankfully I found a very good tutorial on the cloudflare website to implement a suitable cloudflare worker. Thanks to this page I found a way. |
Beta Was this translation helpful? Give feedback.
As mentioned by @s3812497 - if you're hitting similar errors on cloudflare-pages only, double check your dependencies for compatibility with cloudflare workers.