Skip to content

Commit 1c7fbdd

Browse files
authored
fix(example): move express-basic-auth function to api/ directory (#308)
* 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.
1 parent e3dcedf commit 1c7fbdd

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

.github/workflows/check-dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3232
with:
33-
node-version: 22
33+
node-version: 24
3434
cache: pnpm
3535

3636
- name: Install dependencies

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Node.js
2424
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
2525
with:
26-
node-version: 22.x
26+
node-version: 24.x
2727
cache: pnpm
2828

2929
- name: Install dependencies
@@ -48,7 +48,7 @@ jobs:
4848
- name: Setup Node.js
4949
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
5050
with:
51-
node-version: 20
51+
node-version: 24
5252

5353
- name: Setup pnpm
5454
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
@@ -71,7 +71,7 @@ jobs:
7171
- name: Setup Node.js
7272
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
7373
with:
74-
node-version: 20
74+
node-version: 24
7575

7676
- name: Setup pnpm
7777
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
@@ -94,7 +94,7 @@ jobs:
9494
- name: Setup Node.js
9595
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
9696
with:
97-
node-version: 20
97+
node-version: 24
9898

9999
- name: Setup pnpm
100100
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0

.github/workflows/example-angular.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install Node.js
1818
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
1919
with:
20-
node-version: 20
20+
node-version: 24
2121
cache: pnpm
2222

2323
- name: build

.github/workflows/example-nextjs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Node.js
2121
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
2222
with:
23-
node-version: 20
23+
node-version: 24
2424
cache: pnpm
2525

2626
- run: |

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22
1+
v24

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59538,7 +59538,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
5953859538
/***/ ((module) => {
5953959539

5954059540
"use strict";
59541-
module.exports = JSON.parse('{"name":"vercel-action","version":"41.1.4","private":true,"packageManager":"pnpm@10.15.0","author":{"name":"Minsu Lee","email":"amond@amond.net","url":"https://amond.dev"},"license":"MIT","repository":{"type":"git","url":"https://github.com/amondnet/vercel-action"},"keywords":["GitHub","Actions","Vercel","Zeit","Now"],"main":"index.js","engines":{"node":"22.x"},"scripts":{"lint":"eslint .","lint:fix":"eslint . --fix","start":"node ./index.js","build":"ncc build index.js -o dist","test":"jest","all":"pnpm lint && pnpm build && pnpm test","prepare":"husky"},"dependencies":{"@actions/core":"^1.10.0","@actions/exec":"^1.0.3","@actions/github":"^2.1.1","@octokit/webhooks":"latest","axios":"^1.6.8","common-tags":"^1.8.0","vercel":"41.1.4"},"devDependencies":{"@antfu/eslint-config":"^3.0.0","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@vercel/ncc":"^0.36.0","eslint":"^9.9.0","husky":"^9.1.7","jest":"^29.4.0"}}');
59541+
module.exports = JSON.parse('{"name":"vercel-action","version":"41.1.4","private":true,"packageManager":"pnpm@10.15.0","author":{"name":"Minsu Lee","email":"amond@amond.net","url":"https://amond.dev"},"license":"MIT","repository":{"type":"git","url":"https://github.com/amondnet/vercel-action"},"keywords":["GitHub","Actions","Vercel","Zeit","Now"],"main":"index.js","engines":{"node":"24.x"},"scripts":{"lint":"eslint .","lint:fix":"eslint . --fix","start":"node ./index.js","build":"ncc build index.js -o dist","test":"jest","all":"pnpm lint && pnpm build && pnpm test","prepare":"husky"},"dependencies":{"@actions/core":"^1.10.0","@actions/exec":"^1.0.3","@actions/github":"^2.1.1","@octokit/webhooks":"latest","axios":"^1.6.8","common-tags":"^1.8.0","vercel":"41.1.4"},"devDependencies":{"@antfu/eslint-config":"^3.0.0","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@vercel/ncc":"^0.36.0","eslint":"^9.9.0","husky":"^9.1.7","jest":"^29.4.0"}}');
5954259542

5954359543
/***/ })
5954459544

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ app.use(
1111
challenge: true
1212
})
1313
);
14-
app.use(express.static(__dirname + '/_static'));
14+
app.use(express.static(__dirname + '/../_static'));
1515

1616
app.listen(4444, () => console.log('Listening on port 4444...'));

example/express-basic-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "express-basic-auth-example",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"main": "api/index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},

example/express-basic-auth/vercel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ export const config = {
44
deploymentEnabled: false,
55
},
66
functions: {
7-
'index.js': {
8-
includeFiles: '_static/**/*.js',
7+
'api/index.js': {
8+
includeFiles: '_static/**',
99
},
1010
},
1111
rewrites: [
1212
{
1313
source: '/(.*)',
14-
destination: '/index.js',
14+
destination: '/api/index.js',
1515
},
1616
],
1717
};

0 commit comments

Comments
 (0)