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
Netlify Identity not working when using Edge Functions #5235
Comments
@ascorbic perhaps you might have some idea if there's some support we're missing? |
Does the project build okay then? Only 404's when the site is live and trying to hit that endpoint? I'm wondering if a redirect would work here as a workaround. I'll dig more into it, but this might be a temp fix.
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async () => {
throw redirect(
301,
'https://example.com/.netlify/identity'
);
};
[[redirects]]
from = "/admin"
to = "https://example.com/.netlify/identity" |
The project did build okay the last time I tested it, but I haven't messed with that in a while now. I can repro my old project (with updated dependencies) some time this week to verify it it still causes issues. |
Okay, I'm going to look into this. One thing I noticed is that |
I'm pretty sure my actual project had |
I can confirm the issue is still occurring. It works on this commit, but not this one. Navigating to |
This is kind of an issue how edge functions are handled by Netlify. Issue is that by using (I opened at Netlify's forum but their soution is a bit overcomplicated imho: https://answers.netlify.com/t/how-to-use-netlify-identity-with-edge-functions-sveltekit/75634) I wrote a very dirty solution for it. I'm replacing the regex pattern created by the adapter to Here is how I did this with a onBuild build plugin: import { readFile, writeFile } from 'fs/promises'
/**
* Keep /.netlify/* endpoints getting caught by edge function pattern
*/
export const onBuild = async function ({ build }) {
try {
const file = await readFile('.netlify/edge-functions/manifest.json', {encoding: 'utf8'}).then(s => JSON.parse(s))
// https://regex101.com/r/ldVrTI/1
// This will actually ignore all routes starting with ".". => /.*/*
file.functions[0].pattern = '^/[^.].*$'
await writeFile('.netlify/edge-functions/manifest.json', JSON.stringify(file))
} catch (err) {
build.failBuild(err)
}
} |
We're adding support for negative matchers. It's currently experimental, but can add it to the adapter when it's a stable. It would be good to think of which other routes would need excluding. |
Any updates on this, I can't see any workaround documented |
A workaround is listed here: #10584 (point 4 of alternatives considered) EDIT: Looks like this is already mentioned above |
Generate an edge function config that ignores the `.netlify` path (actually, any root path starting with `.`). This avoids conflicts with things like Netlify Identity. Fixes sveltejs#5235.
Generate an edge function config that ignores the `.netlify` path (actually, any root path starting with `.`). This avoids conflicts with things like Netlify Identity. Fixes sveltejs#5235.
Describe the bug
When using
adapter-netlify
and enabling the experimental Edge Functions, Netlify Identity doesn't work. Thehttps://example.com/.netlify/identity
path gets a 404 from SvelteKit, but it should be handled by Netlify (or at least I think so).Using the adapter without the Edge Functions enabled doesn't break Netlify Identity.
Reproduction
Stackblitz fork.
Logs
The Firefox browser console shows `[XHR] GET https://example.com/.netlify/identity/settings [HTTP/2 404 Not Found 31ms]`
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: