forked from ChandelAnish/hireHUB-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (27 loc) · 1.09 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require('dotenv').config()
const express = require("express")
const mysql = require("mysql2")
const path = require('path')
const router=require('./router/router')
const cors=require('cors')
const app = express()
app.use(cors({
origin:['https://asc-hirehub.netlify.app','http://127.0.0.1:5502']
}))
const connectDB = require('./connectionDB/connectionDB')
const { link } = require("fs")
//middlewares
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(express.static('./public'))
app.use(express.static('./public/main-page'))
app.use('/',router)
//main-page
app.get('/mainpage', (req, res) => {//don't use '/main-page' because this will give r=error since '/main-page' is a folder
return res.status(200).redirect('./main-page/index1.html')//as frontend request /index1.html server redirects to ./main-page/index1.html'
// res.sendFile(path.resolve(__dirname,'./public/main-page/index1.html'))//as frontend request /index1.html server send this file
})
const port = process.env.PORT || 5000
app.listen(port, () => {
console.log("the server is listening at ",port)
})