簡體   English   中英

節點 js 路由在本地主機上工作但不在 AWS ec2 實例上

[英]Node js route working on localhost but not on AWS ec2 instance

我現在正在做一個項目,我已經創建了一個提供 HTML 文件的快速服務器這里是服務器的代碼

const express = require('express')
const app = express();
const port = process.env.PORT || 3000;
const staticRequests = require('./Routes/staticRequestHandler');
const individualRegister = require('./Routes/IndividualRegistrationHandler');
const individualPaymentHandler = require('./Routes/individualPaymentHandler');
const instituteRegister = require('./Routes/registrationHandler');
const paymentHandler = require('./Routes/paymentHandler');
const {emailHandler} = require('./Routes/emailHandler');
const loginHandler = require('./Routes/loginHandler');
const examHandler = require('./Routes/examHandler');
const instituteRegistrationHandler = require('./Routes/excelFileHandler');
const instituteIndexRoutes = require('./Routes/institute-index');
const {verifyEndPoint} = require('./Routes/phoneVerificationHandler');
const reviewHandler = require('./Routes/reviewHandler');
const coordRegHandler = require('./Routes/coordinatorRegHandler');
const verifyCaptcha =require('./Routes/verifyCaptcha');
const saveContact = require('./Routes/contact');

// MiddleWare
app.use(express.static('public'))
app.use(express.json());
app.use(express.urlencoded({extended: true}));

// Routes for serving HTML

//public paths
app.use('/IndividualPaymentLink?:id', express.static('public/html files/individualPayment.html'))
app.use('/register', express.static('public/html files/student-register.html'));
app.use('/instituteRegister', express.static('public/html files/institute-register.html'));
app.use('/login', express.static('public/html files/login.html'))
app.use('/forgotPassword', express.static('public/html files/forgotPassword.html'))
app.use('/resetPassword', express.static('public/html files/resetPassword.html'))
app.use('/institutePage', express.static('public/html files/institute-index.html'))
app.use('/examRegistration', express.static('public/html files/addExams.html'))
app.use('/getStudentDetails?:examId', express.static('public/html files/displayStudents.html'))
app.use('/payment?:orderId', express.static('public/html files/paymentPage.html'))
app.use('/FAQs', express.static('public/html files/FAQ.html'))
app.use('/SISO', express.static('public/html files/SISO.html'))
app.use('/SIMO', express.static('public/html files/SIMO.html'))
app.use('/SIEO', express.static('public/html files/SIEO.html'))
app.use('/GRADS', express.static('public/html files/GRADS.html'))
app.use('/FINANCE', express.static('public/html files/FINANCE.html'))
app.use('/aboutus', express.static('public/html files/aboutus.html'))
app.use('/reviews', express.static('public/html files/reviews.html'))
app.use('/coordinator', express.static('public/html files/coordinator.html'))
app.use('/SICO', express.static('public/html files/SICO.html'))
app.use('/NGvUqENEBkY3ZFTJSDQfXcIQfObhfIuavKbWZWn4GOYwleCXcz', express.static('public/html files/thankYou.html'))
app.use('/schedule', express.static('public/html files/schedule.html'))



//routes

app.get(['/getFAQs', '/getReviews', '/getAnnouncements', '/getStats', '/countries', '/getStates', '/getCities?:state', '/getDates'],staticRequests)
app.post('/registerIndividual', individualRegister);
app.get('/individualOrderDetails?:orderId', individualPaymentHandler) 
app.post(['/studpaymentSuccess', '/studpaymentFailure'], individualPaymentHandler)
app.post('/register-institute', instituteRegister);
app.get('/verify', emailHandler); // verify institute email
app.post('/recoverPassword', emailHandler);
app.get('/verifyToken?:token', loginHandler);
app.post(['/reset', '/login-institute'], loginHandler); // reset institute password
app.get(['/getExams?:type','/getPrice?:totalExams?:totalStudents'], examHandler);
app.post('/registerInstituteExam', instituteRegistrationHandler);
app.post('/submitReview', reviewHandler);
app.get('/getRegisteredExams?:name',instituteIndexRoutes);
app.post(['/registerCoordinator', '/sendOtp'], coordRegHandler);
app.post('/verifyCaptcha', verifyCaptcha);
app.post(['/paymentSuccess', '/paymentFailure'], paymentHandler)
app.get('/orderDetails?:orderId', instituteRegistrationHandler)
app.post('/saveContact', saveContact);
app.get('/getRegisteredStudents?:examId', instituteIndexRoutes);
app.get('/S/:id', verifyEndPoint); // verify institute mobile no
app.get('/getPincodeDetails?:pincode', staticRequests); // get state and city from pincode

app.use('*', express.static('public/html files/404.html'))

app.listen(port, '0.0.0.0', () => console.log(`Server started on port ${port}!`));

上面的代碼在 localhost 上運行良好,一切正常,但我有一個 AWS ec2 ubuntu 實例。 當我在那里部署這段代碼時,除了下面的一條之外,每條路線都可以完美運行

app.use('/IndividualPaymentLink?:id', express.static('public/html files/individualPayment.html'))

當我嘗試 go 到上述鏈接時,我被重定向到 404 頁面? 我幾乎通讀了 StackOverflow 和其他任何地方的所有可能示例,但我無法理解問題所在?

問題已解決,問題是文件名的大小寫錯誤,原來的名稱是 InstitutePayment ,我使用了 InstitutePayment

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM