I have deploy my angular and node project on same hosting server.
my angular project url is like http://mysitedomain.com/myangularapp and my node is running on http://105.22.90.6:61001.
I am redirecting all api url like http://mysitedomain.com/api to http://105.22.90.6:61001/
I have written .htaccess as follow
RewriteEngine On
RewriteBase /
RewriteRule ^api$ http://105.22.90.6:61001/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*)$ http://103.21.90.6:61000/$1 [P,L]
When i hit url http://mysitedomain.com/api it works fine, means it redirect to node server.
But when i hit url http://mysitedomain.com/api/login, it gives error Cannot GET /login.
i think i am missing something in last line of above code. I have tired different things but they are not working.
Can anybody give me solution on this.
This is my main server file
const express = require('express');
const http = require('http');
const cors = require('cors');
const hostname = '105.22.90.6:61001';
const port = 61001;
const api = require('./routes/api');
const app = express();
app.use('/api',api);
app.use(cors(corsOptions));
app.get('/', function(req, res){
/*console.dir(req.hostname);
console.dir(req.ip);*/
res.send('Hello Admin API');
});
app.listen(port,hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
And this is my api file
const express = require('express');
const router = express.Router();
const mysql = require('mysql');
router.get('/', (req, res) => {
console.log('yeah its working');
res.send('From Api route');
});
router.get('/login', (req, res) => {
res.send('In Login API');return false;
});
/*End API */
module.exports = router;`