Im working on an Angular / Laravel project , but I’m facing troubles configuring the Grunt proxy properly, I've followed several tutorials and made some research in order to solve this issue , but I haven’t Succeded.
The problem is that the configured Proxy is not redirecting to the host as it should be, I setted to forward request from /localhost:9000/api
to /localhost:8000/api
, but when I make a request :
Referer URL : http://localhost:9000/api/whataver
Request URL : http://localhost:9000/api/whatever
Is making a request to the same host, so the requests are not be proxy correctly, any suggestions?
Here's part of my grunt file:
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: '127.0.0.1',
livereload: 35729
},
proxies: [
{
context: '/api',
host: '127.0.0.1',
port: 8000,
https: false,
changeOrigin: false
}
],
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= yeoman.app %>'
],
middleware: function (connect,options) {
var middlewares = [];
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
// Set up the proxy
middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);
//server static files
middlewares.push(
modRewrite(['^[^\\.]*$ /index.html [L]']),
connect.static('.tmp'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect.static(appConfig.app)
);
return middlewares;
}
}
}
I'd appreciate any help, Thank you!