-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
chore: tmp solution for runtime server loader path #12243
Conversation
WalkthroughThe update in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Size Change: +124 B (0%) Total Size: 9.9 MB
ℹ️ View Unchanged
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12243 +/- ##
==========================================
- Coverage 28.41% 28.41% -0.01%
==========================================
Files 492 492
Lines 15166 15167 +1
Branches 3626 3627 +1
==========================================
Hits 4310 4310
- Misses 10084 10085 +1
Partials 772 772 ☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- packages/renderer-react/src/dataFetcher.ts (1 hunks)
Additional comments (2)
packages/renderer-react/src/dataFetcher.ts (2)
- 15-18: The temporary solution for customizing the server loader request path uses a global variable
serverLoaderPath
or falls back tobasename
. While this approach addresses the immediate need, consider the following:
- Security/PII Leakage: Ensure that the use of
window.location.href
in constructing the query does not inadvertently expose sensitive information.- Maintainability: The FIXME comment is helpful, but it would be beneficial to track this workaround with a more formal tracking system (e.g., issue tracker) to ensure it's addressed in future refactoring efforts.
- Performance: Verify that this dynamic URL construction does not introduce significant performance overhead, especially in high-traffic scenarios.
Would you like assistance in creating a tracking issue for this FIXME?
- 12-21: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [22-24]
The
withEndSlash
utility function correctly ensures that a given string ends with a slash. This is a simple yet effective way to handle URL path construction.
// FIXME: 先临时解自定义 serverLoader 请求路径的问题,后续改造 serverLoader 时再提取成类似 runtimeServerLoader 的配置项 | ||
const url = `${withEndSlash( | ||
(window as any).serverLoaderPath || basename, | ||
)}__serverLoader?${query}`; |
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.
Consider using a more robust method for URL construction to avoid potential issues with path concatenation. For example, using the URL
or URLSearchParams
API can provide a safer and more predictable way to construct URLs, especially when dealing with query parameters and base paths.
- const url = `${withEndSlash((window as any).serverLoaderPath || basename,)}__serverLoader?${query}`;
+ const serverLoaderBasePath = (window as any).serverLoaderPath || basename;
+ const serverLoaderURL = new URL(`__serverLoader?${query}`, withEndSlash(serverLoaderBasePath));
+ const url = serverLoaderURL.toString();
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// FIXME: 先临时解自定义 serverLoader 请求路径的问题,后续改造 serverLoader 时再提取成类似 runtimeServerLoader 的配置项 | |
const url = `${withEndSlash( | |
(window as any).serverLoaderPath || basename, | |
)}__serverLoader?${query}`; | |
// FIXME: 先临时解自定义 serverLoader 请求路径的问题,后续改造 serverLoader 时再提取成类似 runtimeServerLoader 的配置项 | |
const serverLoaderBasePath = (window as any).serverLoaderPath || basename; | |
const serverLoaderURL = new URL(`__serverLoader?${query}`, withEndSlash(serverLoaderBasePath)); | |
const url = serverLoaderURL.toString(); |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- packages/renderer-react/src/dataFetcher.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/renderer-react/src/dataFetcher.ts
临时方案解运行时自定义 serverLoader 请求路径的需求,不进 Changelog
最终解会在后续改造 serverLoader 时做,提供类似
ssr.runtimeServerLoader
的配置项Summary by CodeRabbit