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

feat: on demand revalidation route #1020

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from

Conversation

okdv
Copy link
Contributor

@okdv okdv commented Sep 27, 2022

Description

API route for forcing revalidation of nextjs cache

User must have .env.local setup and it should contain variable REVALIDATION_SECRET, which will be supplied in api call for extra security

Can then revalidate paths with following url (local example)
GET http://localhost:3000/web-map-beta/demo/api/revalidate?secret=TOKEN&path=/top
401 if token is bad
404 if path is bad
500 if error with revalidation function
200 if success

Will add applicable README changes in this PR, once we confirm this is built as desired

Will also add a test for this change, again once confirm its built as desired

Fixes #998 (discovery thread with @dadiorchen )

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Cypress integration
  • Cypress component tests

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@okdv okdv marked this pull request as draft September 27, 2022 20:40
@okdv
Copy link
Contributor Author

okdv commented Sep 27, 2022

meant to open as draft, changed it after the fact

@dadiorchen
Copy link
Collaborator

Oh, this is amazing, thanks for helping to consider the security problem.

@okdv
Copy link
Contributor Author

okdv commented Oct 5, 2022

@dadiorchen for sure! I did notice I accidentally am throwing the wrong 4XX errors at some points, will get those updated and set this ready for review

@okdv
Copy link
Contributor Author

okdv commented Dec 11, 2022

@dadiorchen i think this takes care of the cache revalidation IIRC, i just never finished a small bug and put it out of draft. I'll take care of that

@okdv
Copy link
Contributor Author

okdv commented Dec 30, 2022

fixed the little bug i mentioned but had forgotten about, submitting for review now

might be a good idea to add a bit into the README about this as well, thoughts on if that is necessary @dadiorchen ?

@okdv okdv marked this pull request as ready for review December 30, 2022 20:04
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

Successfully merging this pull request may close these issues.

Research: could we manually trigger the cache update for next.js
2 participants