Svelte(kit) error page renders after deploying

Hi,

After I deploy my Sveltekit project it renders the error page:

https://6367dde78c085d64a6d8798f--delightful-dango-35c0fa.netlify.app

GET https://6367dde78c085d64a6d8798f--delightful-dango-35c0fa.netlify.app/__data.json 404

SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Searched a lot but didn’t managed to resolve the issue.

No idea what __data.json is, it’s not in the project, but causing the error here.

  • Sveltekit and adapter-netlify are updated to the latest version.

  • In the project I have a couple of API calls using Fetch, but just one uses ‘Content-type’: ‘application/x-www-form-urlencoded’ in the headers. so I’m not sure if that’s parsing HTML instead of JSON error.

The above are the things I found from search and didn’t help.

I appreciate any help.

I can see you’re using adapter/static: Netlify App. Is that expected. Did you intend to use adapter/netlify?

That’s strange !

I promise I’ve switched between static and netlify adapter a few times since last day - as simple as uncommenting netlify adapter and commenting static one -, then built an uploaded every build, and none worked this time changing the adapter to netlify it worked !!

But in netlify docs I think it said, netlify would work with static adapter as well, am I right?

import preprocess from 'svelte-preprocess';
// import adapter from '@sveltejs/adapter-static';
import adapter from '@sveltejs/adapter-netlify';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter()
            // adapter: adapter({
            // 	pages: 'build',
            // 	assets: 'build',
            // 	domain: null,
            // 	jekyll: false,
            // 	fallback: 'index.html',
            // 	precompress: false
            // })
    },

    preprocess: [
        preprocess({
            postcss: true
        })
    ]
};

export default config;

Thanks tho for pointing that.

Hello @netman - thanks for the update here! Could you share with us where you see adapter/static as supported in our documentation? Thanks!

Alternatively, you can use @sveltejs/adapter-static for a fully static site, and it will also work successfully with Netlify.

It says for a fully static site though.

Yeah, that adapter would work for static sites, but yours doesn’t seem to be one, based on the type of file (data.json) that your site is requiring.

1 Like