-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Shadow endpoints #3679
Shadow endpoints #3679
Conversation
🦋 Changeset detectedLatest commit: 238d1b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✔️ Deploy Preview for kit-demo canceled. 🔨 Explore the source changes: 238d1b0 🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/61fc0796b4445200075fb7f9 |
As mentioned in #3532, we need to accommodate prerendering. I think the neatest way to do this is to make shadow endpoint data available at Maybe |
Co-authored-by: Conduitry <git@chor.date>
This pull request is being automatically deployed with Vercel (learn more). kit-svelte-dev – ./sites/kit.svelte.dev🔍 Inspect: https://vercel.com/svelte/kit-svelte-dev/3JHuew9mkoZXXbBbXfCD8yg9KZML |
if (status >= 400) { | ||
return { | ||
status, | ||
error: new Error('Failed to load data') | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now possible in @sveltejs/kit@1.0.0-next.361
#5314
Is there a way to distinguish an error page rendered due to a shadow endpoint's 4xx
or 5xx
response?
Used to fetch endpoints in the load
function, and return custom error messages according to the response.
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit';
export const load: Load = async ({ fetch }) => {
const response = await fetch('/path/to/endpoint');
if (!response.ok) return { error: 'Custom Error Message' };
return { status: 200 };
};
</script>
Above no longer seems feasible since the error message defaults to Failed to load data
.
Checking for error.message === 'Failed to load data'
in the __error.svelte
seems wrong.
Hi, This change has broken the demo application build process for static adapter. It now shows a 500 error: Steps to reproduce: Use TypeScript? … Yes cd functions Change adaptor to static in svelte.config.js Install the static adapter: Build project npm run build
vite v2.8.0 building for production... Run npm run preview to preview your production build locally.
What has changed:
|
This PR implements shadow endpoints — see #3532.
${path}/__data.json
GET
methodsaccept
does not includetext/html
invalidate('/foo')
should invalidate/foo/__data.json
(at least conceptually)Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0