New Update to Seed API Proxy Added

New Update to Seed API Proxy Added

Hello all, 

if any of you are using the seed feel free to update to the newest version, I have added the ability to proxy your api locally without the need to deal with CORS. 

 

its a simple configuration change on your part, 

just download the seed, run npm install and configure your proxy settings 

All you do is open gulp.js and change the following information

gulp.task('browser-sync', function() {
var proxyOptions = url.parse('https://www.someserver.com/api'); //This points the local folder to a remote location to get data
proxyOptions.route = '/api';//This is the local pointer to your api
browserSync({
server: {
baseDir: "../public",
middleware: [ Proxy(proxyOptions), historyApiFallback() ]
}
});
});

 

The URL is the location of your api server

The Folder is the local call you would make to get your API 

so if your api call was 

www.someserver.com/api/users/get/1/

then you could now write it 

/api/users/get/1/

and the local system would send the request out to the server and make it look like you were coming from your local enviroment . 

this way you don't have to write code or change your path location when going from a local development enviroment to a remote one.

 

Cheers. 

Ray

要查看或添加评论,请登录

Raymond Bayly的更多文章

社区洞察

其他会员也浏览了