I tried to setup grunt + connect to proxy request to /api into local apache for PHP back-end (i.e http://localhost:9000/api would be proxied to http://localhost:80). But when i requested http://localhost:9000/api it says Cannot GET /api
Below are excerpt from my Gruntfile (generated by yeoman and edited for my project). If required, i can post my full Gruntfile
First i define proxy and proxyOption at top of the file
var url = require('url');
var proxy = require('proxy-middleware');
var proxyOption = url.parse('http://localhost');
proxyOption.route = '/api';
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
Grunt has nothing to do with this project. See the readme and test/test.js for examples of how to use this code. Or just read the source; it's a whopping 80 lines of code.
I tried to setup grunt + connect to proxy request to
/api
into local apache for PHP back-end (i.ehttp://localhost:9000/api
would be proxied tohttp://localhost:80
). But when i requestedhttp://localhost:9000/api
it saysCannot GET /api
Below are excerpt from my Gruntfile (generated by yeoman and edited for my project). If required, i can post my full Gruntfile
First i define
proxy
andproxyOption
at top of the fileThen add the middleware on
initConfig