Skip to content

Commit

Permalink
bug fixed again
Browse files Browse the repository at this point in the history
  • Loading branch information
devvrat011 committed Mar 1, 2024
1 parent c49e7cb commit 5338c0a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import express from 'express';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import cors from 'cors';
import userRoutes from './routes/user.route.js';
import authRoutes from './routes/auth.route.js';
import postRoutes from './routes/post.route.js';
Expand All @@ -20,27 +19,26 @@ mongoose
console.log(err);
});

const __dirname = path.resolve();
const __dirname = path.resolve();

const app = express();

app.use(express.json());
app.use(cookieParser());
app.use(cors());

app.listen(3000, () => {
console.log('Server is running on port 3000!');
});

app.use('/api/user', userRoutes);
app.use('/api/auth', authRoutes);
app.use('/api/post',postRoutes);
app.use('/api/comment',commentRoutes);
app.use('/api/post', postRoutes);
app.use('/api/comment', commentRoutes);

app.use(express.static(path.join(__dirname,'/client/dist')));
app.use(express.static(path.join(__dirname, '/client/dist')));

app.get('*', (req,res) => {
res.sendFile(path.join(__dirname, 'client' , 'dist' , 'index.html'));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client', 'dist', 'index.html'));
});

app.use((err, req, res, next) => {
Expand All @@ -51,4 +49,4 @@ app.use((err, req, res, next) => {
statusCode,
message,
});
});
});

0 comments on commit 5338c0a

Please sign in to comment.