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

fix(netlify): fix conflict between Netlify Identity and edge function rendering #12052

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

serhalp
Copy link

@serhalp serhalp commented Mar 28, 2024

Fixes #5235.

When using edge functions with Netlify, the generated edge function was configured to run against all paths. This conflicted with the expectation that paths under .netlify/ (such as .netlify/identity/settings) are ignored by the framework.

At the time #5235 was opened, this was difficult to solve, but Netlify now supports path exclusions in edge function configuration, hence this PR.

While I was here, I also added an exclusion to avoid unnecessarily invoking this edge function on static files. Currently it's just a no-op, but it's still nice to avoid the unnecessary invocation.

Testing this is a bit involved, but I was able to repro the issue in #5235 and to confirm this fixes it. We should probably add proper integration tests here eventually.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Previously Netlify Edge Functions didn't support a way to configure path
matching that *excludes* paths.

Now that it does, we can avoid running the "render" edge function on
static assets. Currently, it's [just a
no-op](https://github.com/sveltejs/kit/blob/80386437030c5c79913e859e3c32fd194613e1b6/packages/adapter-netlify/src/edge.js#L18-L22),
but it's still nice to avoid the invocation.
Copy link

changeset-bot bot commented Mar 28, 2024

🦋 Changeset detected

Latest commit: 5c3e74a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-netlify Patch

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

@serhalp serhalp force-pushed the serhalp/fra-186-sveltekit-adapter-should-generate-edge-functions-that-dont branch from e87b06a to 5c3e74a Compare March 28, 2024 21:21
@serhalp serhalp marked this pull request as ready for review March 28, 2024 21:23
Comment on lines +16 to +17
* TODO(serhalp) Replace this custom type with an import from `@netlify/edge-functions`,
* once that type is fixed to include `excludedPath` and `function`.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I'm working on this as well. I should have a follow-up PR soon.

@serhalp
Copy link
Author

serhalp commented Apr 22, 2024

Hi @benmccann, nice to meet you! Is there anything I need to do to get this PR merged and released? Please let me know. Thanks!

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

Successfully merging this pull request may close these issues.

Netlify Identity not working when using Edge Functions
2 participants