fix(example): move express-basic-auth function to api/ directory - #308
Conversation
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 addresses a critical deployment issue for the 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. 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. Footnotes
|
|
Deploy preview for team-scope-test ready! ✅ Preview Built with commit e938762. |
There was a problem hiding this comment.
No issues found across 2 files
Auto-approved: Updates example structure to comply with Vercel CLI v41+ requirements; low risk as it only affects an example directory.
Architecture diagram
sequenceDiagram
participant Client as Client Browser
participant Router as Vercel Edge Router
participant App as Serverless Function (Express)
participant Storage as File System (_static/)
Note over Router,App: Vercel CLI v41+ Routing Flow
Client->>Router: GET /path
Router->>Router: CHANGED: Apply rewrite to /api/index.js
Router->>App: Invoke Serverless Function
Note over App: Basic Auth Middleware
alt Auth Success
App->>Storage: CHANGED: Resolve static assets via ../_static
Storage-->>App: File data
App-->>Client: 200 OK (Static content)
else Auth Failure
App-->>Client: 401 Unauthorized (WWW-Authenticate)
end
There was a problem hiding this comment.
Code Review
This pull request refactors the express-basic-auth example by moving the main index.js file into an api subdirectory and adjusting the path to the static assets directory (_static) to be one level up from the new api directory. The vercel.ts configuration has been updated to reflect these changes, correctly pointing to the new function entry point at /api/index.js and including static files from ../_static/**. There are no review comments to address.
There was a problem hiding this comment.
Pull request overview
Updates the example/express-basic-auth deployment configuration and code layout to satisfy Vercel CLI v41+ expectations that Serverless Functions live under the api/ directory.
Changes:
- Update
functionsandrewritesin the example’s Vercel config to referenceapi/index.js. - Adjust Express static asset path to account for the function now living under
api/.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| example/express-basic-auth/vercel.ts | Points function config and rewrites at api/index.js, updates bundled static files glob. |
| example/express-basic-auth/api/index.js | Updates static directory resolution for the new directory structure. |
Comments suppressed due to low confidence (1)
example/express-basic-auth/api/index.js:16
- This file is now under
api/, so it will be deployed as a Vercel Serverless Function. In that runtime, callingapp.listen(...)is generally incorrect (it can hang the invocation), and nothing is exported for the platform to invoke. Consider exporting the Express app/handler (e.g.,module.exports = app) and guardingapp.listenso it only runs when executed directly for local development.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'index.js': { | ||
| includeFiles: '_static/**/*.js', | ||
| 'api/index.js': { | ||
| includeFiles: '../_static/**', |
There was a problem hiding this comment.
includeFiles is set to ../_static/**, but Vercel function config patterns appear to be evaluated relative to the project root (same as the functions key path). Using .. likely won’t match the intended _static folder and can cause missing static assets at runtime. Consider changing this to _static/** (or another root-relative glob that matches the folder you want bundled).
| includeFiles: '../_static/**', | |
| includeFiles: '_static/**', |
There was a problem hiding this comment.
✅ Applied in 253fbdb
- File:
example/express-basic-auth/vercel.ts - Change: Updated
includeFilesfrom'../_static/**'to'_static/**'(root-relative glob matching Vercel's project-root evaluation)
Thanks for the suggestion, @copilot-pull-request-reviewer!
| 'api/index.js': { | ||
| includeFiles: '../_static/**', |
There was a problem hiding this comment.
After moving the entrypoint into api/index.js, the example package metadata still points at index.js (e.g., package.json#main). This will break local usage like node ./require() and is confusing for the example. Consider updating the example’s package.json to reference the new entrypoint (or add a small root index.js that forwards to api/index.js).
There was a problem hiding this comment.
✅ Applied in 253fbdb
- File:
example/express-basic-auth/package.json - Change: Updated
mainfrom'index.js'to'api/index.js'to match the moved entrypoint
Thanks for the suggestion, @copilot-pull-request-reviewer!
Vercel CLI v41+ requires serverless functions to be inside the `api/` directory. The `functions` config referencing `index.js` at the project root no longer works, causing deployment error: "The pattern 'index.js' defined in functions doesn't match any Serverless Functions inside the api directory." - Move index.js to api/index.js - Update functions pattern and rewrites destination in vercel.ts - Update includeFiles and static path for new directory structure
…-basic-auth - Change includeFiles from '../_static/**' to '_static/**' (root-relative) - Update package.json#main from 'index.js' to 'api/index.js' to reflect moved entrypoint
Align all CI workflows, .nvmrc, and check-dist with the node24 runtime update in action.yml and package.json engines (24.x). Rebuild dist/ with Node 24 to match.
c4e71a3 to
e938762
Compare
|
* fix(example): move express-basic-auth function to api/ directory Vercel CLI v41+ requires serverless functions to be inside the `api/` directory. The `functions` config referencing `index.js` at the project root no longer works, causing deployment error: "The pattern 'index.js' defined in functions doesn't match any Serverless Functions inside the api directory." - Move index.js to api/index.js - Update functions pattern and rewrites destination in vercel.ts - Update includeFiles and static path for new directory structure * fix(example): fix includeFiles path and package.json main for express-basic-auth - Change includeFiles from '../_static/**' to '_static/**' (root-relative) - Update package.json#main from 'index.js' to 'api/index.js' to reflect moved entrypoint * ci: update workflow node version and .nvmrc to 24 Align all CI workflows, .nvmrc, and check-dist with the node24 runtime update in action.yml and package.json engines (24.x). Rebuild dist/ with Node 24 to match.


.github/dependabot.ymlYAML style (pre-existing on master)package.jsontonode 24.xbutdist/was built with22.xpackage.jsontonode 24.xand rebuiltdist/pull_request_target(runs base branch code) - will pass after merge.github/dependabot.ymlissue is from master branch (pre-existing)⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.