Skip to content

Commit efe51a1

Browse files
committed
feat(): update vercel config
1 parent f83e6f2 commit efe51a1

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

doc-angular/api/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import('../dist/server/server.mjs')
2+
.then((module) => module.app)
3+
.catch((error) => {
4+
console.error('Failed to load server module:', error);
5+
throw error;
6+
});
7+
export default async (req, res) => {
8+
const { app } = await import('../dist/server/server.mjs');
9+
return app(req, res);
10+
};

doc-angular/src/server.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
AngularNodeAppEngine,
33
createNodeRequestHandler,
4-
isMainModule,
54
writeResponseToNodeResponse,
65
} from '@angular/ssr/node';
76
import express from 'express';
@@ -53,12 +52,12 @@ app.use('/**', (req, res, next) => {
5352
* Start the server if this module is the main entry point.
5453
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
5554
*/
56-
if (isMainModule(import.meta.url)) {
57-
const port = process.env['PORT'] || 4000;
58-
app.listen(port, () => {
59-
console.log(`Node Express server listening on http://localhost:${port}`);
60-
});
61-
}
55+
// if (isMainModule(import.meta.url)) {
56+
// const port = process.env['PORT'] || 4000;
57+
// app.listen(port, () => {
58+
// console.log(`Node Express server listening on http://localhost:${port}`);
59+
// });
60+
// }
6261

6362
/**
6463
* Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions.

doc-angular/vercel.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 2,
3+
"public": true,
4+
"name": "doc-angular-challenges",
5+
"rewrites": [
6+
{
7+
"source": "/(.*)",
8+
"destination": "/api"
9+
}
10+
],
11+
"functions": {
12+
"api/index.js": {
13+
"includeFiles": "dist/**"
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)