简体   繁体   English

节点 js 路由在本地主机上工作但不在 AWS ec2 实例上

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

I am working on a project right now and I have created an express server that serves HTML files here is the code for the server我现在正在做一个项目,我已经创建了一个提供 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}!`));

This above code works perfectly on localhost, everything works fine but I have an AWS ec2 ubuntu instance.上面的代码在 localhost 上运行良好,一切正常,但我有一个 AWS ec2 ubuntu 实例。 when I deploy this code over there every route except for the one below works perfectly当我在那里部署这段代码时,除了下面的一条之外,每条路线都可以完美运行

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

When I try to go to the above link I am redirected to the 404 pages?当我尝试 go 到上述链接时,我被重定向到 404 页面? I have pretty much read through all possible examples on StackOverflow and everywhere else, but I am unable to understand the problem?我几乎通读了 StackOverflow 和其他任何地方的所有可能示例,但我无法理解问题所在?

The issue is solved the problem was that the file name had the wrong casing the original name was InstitutePayment and I used institutePayment .问题已解决,问题是文件名的大小写错误,原来的名称是 InstitutePayment ,我使用了 InstitutePayment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM