refactor: flatten auth json proxy imports#412
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (63)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the application's API proxy infrastructure by consolidating authentication-related JSON proxy logic into a single, dedicated utility. This change addresses the misleading naming and broad usage of the former Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR consolidates the research/_base auth proxy shim into a shared _utils/auth-json-proxy module, since it was being imported by routes outside the research/ directory (e.g., model-endpoints, embedding-settings, newsletter, papers). The legacy shim is deleted and all imports are repointed.
Changes:
- Added
web/src/app/api/_utils/auth-json-proxy.tsas a shared utility exportingapiBaseUrland an auth-enabledproxyJsonwrapper. - Updated ~50 route files to import from the new
@/app/api/_utils/auth-json-proxypath instead ofresearch/_base. - Deleted the legacy
research/_base.tsshim and relocated its test.
Reviewed changes
Copilot reviewed 63 out of 63 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
web/src/app/api/_utils/auth-json-proxy.ts |
New shared auth JSON proxy helper (replaces research/_base.ts) |
web/src/app/api/_utils/auth-json-proxy.test.ts |
Updated test: mock path and import corrected to match new location |
web/src/app/api/research/_base.ts |
Deleted legacy shim |
~50 route.ts files |
Mechanical import path change to @/app/api/_utils/auth-json-proxy |
web/src/app/api/research/repro/context/route.test.ts |
Updated vi.mock path to match new import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Vercel Preview
|
There was a problem hiding this comment.
Code Review
This pull request refactors the authentication-protected JSON proxy helpers into a shared utility auth-json-proxy under web/src/app/api/_utils. This is a great improvement for code organization and maintainability, as it centralizes the logic and replaces many confusing relative imports with a clear, absolute path. The changes are extensive but consistent across the codebase. I've added one suggestion to the new auth-json-proxy.ts file to make the re-export syntax more explicit and concise.
| import { apiBaseUrl, proxyJson as sharedProxyJson } from "./backend-proxy" | ||
| import type { ProxyMethod } from "./backend-proxy" | ||
|
|
||
| export { apiBaseUrl } |
There was a problem hiding this comment.
For better clarity and conciseness, you can use export ... from syntax to directly re-export apiBaseUrl. This makes it explicit that the module is simply passing it through. You can also combine the other imports from ./backend-proxy into a single statement.
| import { apiBaseUrl, proxyJson as sharedProxyJson } from "./backend-proxy" | |
| import type { ProxyMethod } from "./backend-proxy" | |
| export { apiBaseUrl } | |
| export { apiBaseUrl } from "./backend-proxy" | |
| import { proxyJson as sharedProxyJson, type ProxyMethod } from "./backend-proxy" | |



Summary
auth-json-proxyhelper underweb/src/app/api/_utilsresearch/_baseto the shared helper pathresearch/_baseshim and move its focused contract test alongside the new helperWhy
The old
research/_basename had become misleading because it was used acrossresearch,model-endpoints,embedding-settings,newsletter, andpapersroutes. This PR flattens those imports into a generic utility location so the remaining API proxy surface matches the actual module boundaries.Validation
cd web && npx vitest run src/app/api/_utils/auth-json-proxy.test.ts src/app/api/research/repro/context/route.test.ts src/app/api/_utils/backend-proxy.test.tscd web && npx eslint src/app/api/_utils/auth-json-proxy.ts src/app/api/_utils/auth-json-proxy.test.ts src/app/api/research/repro/context/route.test.tscd web && npx tsc --noEmitcd web && npm run build