Hi all,
Very weird but I have a working NodeJS API consisting of:
app.js
route folders
- Route.js files
I have used application manager to assign this app to /myAPI
The app is starting and running.
The GET requests all work.
The weirdset thing is that the POST request is actually being CHANGED to a get request!!!?
If i run the api via:
mydomain.com:3001 the Post request works.
If I use
mydomain.com/myAPI then the POST request is rejected as the enpoint cannot be found. I have checked the terminal output and it is being asked a GET instead of post.
The original C# code doesnt change at all making the request, just the domain name /port.
Has anyone else seen this kind of issue??
In C# I'm using "Method.POST"
API info:
File app.js:
file user.js
As mentioned, if i do it with port, it works and log shows POST
if I use the app manager URl then this errors out and the log says i sent a GET request!!?
Thanks for any ideas
Very weird but I have a working NodeJS API consisting of:
app.js
route folders
- Route.js files
I have used application manager to assign this app to /myAPI
The app is starting and running.
The GET requests all work.
The weirdset thing is that the POST request is actually being CHANGED to a get request!!!?
If i run the api via:
mydomain.com:3001 the Post request works.
If I use
mydomain.com/myAPI then the POST request is rejected as the enpoint cannot be found. I have checked the terminal output and it is being asked a GET instead of post.
The original C# code doesnt change at all making the request, just the domain name /port.
Has anyone else seen this kind of issue??
In C# I'm using "Method.POST"
API info:
File app.js:
Code:
app.use((req,res,next)=>{
res.header("Access-Control-Allow-Origin","*");
res.header("Access-Control-Allow-Headers","Origin,X-Requested-With,Content-Type,Accept,Authorization");
if (req.method === 'OPTIONS'){
res.header('Access-Control-Allow-Methods','PUT,POST,PATCH,DELETE,GET');
return res.status(200).json({});
}
next();
});
const userRoutes = require('./api/routes/user');
app.use('/myAPI/user',userRoutes);
Code:
router.post('/profileSettings/',verify,(req,res) => {
var sqlString = "SET @userID = ?;\
CALL updateuser(@userID);";
try{
connection.query(sqlString,[req.body.user],(err,rows,fields)=>{
//console.log(req.user._id);
if(!err)
{
return res.status(200).json({
Result: true
});
}
else
//console.log(err),
return res.status(460).json({
Result: true
});
})
} catch (e) {
// this catches any exception in this scope or await rejection
console.log(e);
res.status(500).json({ Result: e });
}
});
if I use the app manager URl then this errors out and the log says i sent a GET request!!?
Thanks for any ideas