Skip to content
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

infinite redirect when serving from a subfolder with adapter-static #12736

Open
xucian opened this issue Sep 30, 2024 · 0 comments
Open

infinite redirect when serving from a subfolder with adapter-static #12736

xucian opened this issue Sep 30, 2024 · 0 comments

Comments

@xucian
Copy link

xucian commented Sep 30, 2024

Describe the bug

I have django for backend and (trying to have) svelte on the frontend.
I'm serving the static output of sveltekit via django & whitenoise (but I can also reproduce it with a simple python server, so it's not about django).

in django, I'm returning index.html for any path that doesn't exist:
urls.py

    re_path(r'^(?!static/).*$', serve, {
        'document_root': settings.STATIC_ROOT,
        'path': 'spa/index.html'
    }),

this works fine with an angular-based front-end (using ng build --base-href=/static/spa/) , but svelte is just stuck in a redirect loop no matter what I try.

I'm doing everything I've found in docs. the initial load correctly finds all the js files and the index.html, but it just shows a white page and it infinitely redirects to something -- I can't quite debug it as it's happening really fast.

svelte.config.js

// import adapterAuto from '@sveltejs/adapter-auto';
import adapterStatic from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://kit.svelte.dev/docs/integrations#preprocessors
	// for more information about preprocessors
	preprocess: vitePreprocess(),

	kit: {
		adapter: adapterStatic({
			fallback: 'index.html', // SPA mode // may differ from host to host

			pages: "../.frontend-dist",
		}),
		prerender: {
			entries: []
		},
		paths: {
			base: "/static/spa",
		}
	},
};

export default config;

any help is appreciated

Reproduction

I'm sure this is immediately obvious to maintainers. please just go over my message and I'm sure you'll know why it happens, it's probably a hidden config I'm missing that I'm not aware of

Logs

No response

System Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 161.69 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
  Browsers:
    Chrome: 129.0.6668.60
    Safari: 17.6

Severity

blocking all usage of SvelteKit

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant