I've got an application with AngularJS in front-end and Java Spring 3 in backend.
So when i run grunt-server i use grunt-connect-proxy to contact the backend part form the frontend part.
So my connect configuration is like that :
connect: {
proxies: [
{
context:'/mdp-web',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: true
}
],
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
proxySnippet,
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, cegedimConfig.app)
];
}
}
}
}
But my matter is that in Java the context-root of the application is mdp-web/
But in AngularJS my uri's are like : /api/users
$resource('/api/users', {}, {
query: {
isArray: true,
method:'GET',
cache: HttpCache
}
});
I want to proxy all the /api/ uris but with a redirection to /mdp-web/api
Is it possible to do that with grunt-connect-proxy (maybe with rewrite property) ?
If you get an idea i take it really !
Use a rewrite rule:
proxies: [
{
context:'/api',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: true,
rewrite: {
'^/api': '/mdp-web/api'
}
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With