tirth-2001 / express-typescript-vercel-part2 Goto Github PK
View Code? Open in Web Editor NEWHome Page: express-typescript-vercel-part2.vercel.app
Home Page: express-typescript-vercel-part2.vercel.app
Hi @tirth-2001
Simple and great code!
Btw let's imagine to integrate with React
Ofc It's working with only standalone Express(ts). I am integrating with React(ts). Working on local env. But it showed me up the error while deploying to vercel
Here is the details;
index.ts
import dotenv from "dotenv";
import express, { Express, Request, Response } from "express";
import path from "path";
import cors from "cors";
dotenv.config();
const app: Express = express();
app.use(express.json());
app.use(cors());
app.use(express.static(path.join(__dirname, '../client/build')));
app.get('/*', (req: Request, res: Response) => {
res.sendFile(path.join(__dirname, '../client/build', 'index.html'));
});
const port = process.env.PORT || 8000;
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
vercel.json
{
"version": 2,
"builds": [
{
"src": "dist/index.js",
"use": "@vercel/node",
"config": { "includeFiles": ["dist/**"] }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/index.js"
}
]
}
tsconfig.json
{
"compilerOptions": {
"target": "es2016",
"jsx": "preserve",
"module": "commonjs",
"allowJs": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"exclude": [
"client",
"dist",
"node_modules"
]
}
the error when deploy to vercel; it showed up the Not Found..
Could you let me know if anything is wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.