Svelte Kit Endpoint gives me 404

I made an Svelte Kit its working in my local with no problem but when i build it like this:

import adapter from '@sveltejs/adapter-static';

export default {
    kit: {
        adapter: adapter({
            fallback: 'index.html',
        })
    }
};

And gives me 3 folders and they are: client, prerendered, server.

I'm uploading this 3 folders in my hosting and move the folder files into root folder. Everythings works with no problem BUT i have an api that sends mail. It's gives me 404? Send mail is working in localhost but not working in hosting. I can't fixed it. In manifest.json:

{
    type: 'endpoint',
    id: "api/sendMail",
    pattern: /^\/api\/sendMail\/?$/,
    names: [],
    types: [],
    load: () => import('./entries/endpoints/api/sendMail/_server.js')
},

The path is correct by the way.

The folders in hosting: Photo

What can i do?

Upvotes: 1

Views: 1534

Answers (1)

tbdrz
tbdrz

Reputation: 2190

By specifying a fallback page, this means you're turning SPA mode on, so you can't use server endpoints.

From the adapter-static readme:

You can use adapter-static to create a single-page app or SPA by specifying a fallback page.

The reason this is working local in dev:

During development, SvelteKit will still attempt to server-side render your routes. This means accessing things that are only available in the browser (such as the window object) will result in errors, even though this would be valid in the output app. To align the behavior of SvelteKit's dev mode with your SPA, you can add export const ssr = false to your root +layout.

Upvotes: 1

Related Questions