Skip to content

feat: add withPageAuthRequired for server #2207

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

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

Conversation

guabu
Copy link
Contributor

@guabu guabu commented Jul 2, 2025

📋 Changes

Adds withPageAuthRequired for server-rendered components.

📎 References

Fixes: #1790

🎯 Testing

See EXAMPLES.md for testable examples using the App and Pages router.

@guabu guabu requested a review from a team as a code owner July 2, 2025 07:05
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 85.05747% with 13 lines in your changes missing coverage. Please review.

Project coverage is 84.71%. Comparing base (a063a8d) to head (7a5c077).

Files with missing lines Patch % Lines
src/server/client.ts 48.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2207      +/-   ##
==========================================
+ Coverage   84.23%   84.71%   +0.48%     
==========================================
  Files          22       24       +2     
  Lines        2208     2284      +76     
  Branches      397      420      +23     
==========================================
+ Hits         1860     1935      +75     
- Misses        342      343       +1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@tusharpandey13 tusharpandey13 left a comment

Choose a reason for hiding this comment

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

These changes look good. I have a small suggestion:
getServerSideProps can return 404 or a redirect object too, see https://nextjs.org/docs/pages/api-reference/functions/get-server-side-props#getserversideprops-return-values

I don't think we have tests for these.

@guabu
Copy link
Contributor Author

guabu commented Jul 6, 2025

Thanks for taking a look @tusharpandey13. Since the SDK is the one returning the redirect directive from getServerSideProps, there shouldn't ever be a case where the notFound directive is returned unless we return it explicitly (which we don't).

tusharpandey13
tusharpandey13 previously approved these changes Jul 7, 2025
Copy link
Contributor

@tusharpandey13 tusharpandey13 left a comment

Choose a reason for hiding this comment

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

lgtm

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.

v4 - replacements for with_____Required methods?
3 participants