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

Sveltekit build result works fine in cloud, fails with swa cli #945

Open
2 of 3 tasks
ktarmyshov opened this issue Mar 10, 2025 · 1 comment
Open
2 of 3 tasks

Sveltekit build result works fine in cloud, fails with swa cli #945

ktarmyshov opened this issue Mar 10, 2025 · 1 comment

Comments

@ktarmyshov
Copy link

ktarmyshov commented Mar 10, 2025

Before filing this issue, please ensure you're using the latest CLI by running swa --version and comparing to the latest version on npm.

demo % npx swa --version
2.0.4

Are you accessing the CLI from the default port :4280 ?

  • No, I am using a different port number (--port) and accessing the CLI from that port
  • Yes, I am accessing the CLI from port :4280

Make sure you are accessing the URL printed in the console when running swa start!

  • ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug
The build result of the SvelteKit app with svelte-adapter-azure-swa deployed to the azure swa cloud works fine.

https://polite-desert-00b80111e.2.azurestaticapps.net/

Tests (automated and manual) fail with swa cli.

To Reproduce
This branch is minimally different to main to start swa cli for the demo app

git clone -b feat/update [email protected]:ktarmyshov/svelte-adapter-azure-swa.git
cd svelte-adapter-azure-swa
npm ci
npm pack
cd demo
npm ci
npx playwright install
npm run test:swa

Manual:

Expected behavior
Should work same as azure cloud - should not fail.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Mac OS
  • latest 15.3.1

Additional context
Latest deploy job

https://github.com/geoffrich/svelte-adapter-azure-swa/actions/runs/13660215225/job/38189418604

@ktarmyshov ktarmyshov changed the title SveltekitBuild result works fine in cloud, fails with swa cli Sveltekit build result works fine in cloud, fails with swa cli Mar 10, 2025
@ktarmyshov
Copy link
Author

Der dev team,

more context/research:

It seems there is an issue with SWA serving static/prerenderd content (adding trailing slashes or other).
Here is the repro code without prerendered content. Although one test fails, in this version there is no issue with 404 or too many redirects.

git clone -b feat/update-noprerender [email protected]:ktarmyshov/svelte-adapter-azure-swa.git
cd svelte-adapter-azure-swa
npm ci
npm pack
cd demo
npm ci
npx playwright install
npm run test:swa

geoffrich/svelte-adapter-azure-swa#197 (comment)

Found the issue - seems like SWA always adds the leading slash - so if you access /sverdle the local SWA runtime will redirect you to /sverdle/ but then SvelteKit will redirect you back to /sverdle and so on.

The only way to fix this is to set trailingSlash = 'always' in SvelteKit.

+layout.server.ts:

export const trailingSlash = 'always';

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