मैं अपने कोणीय अनुप्रयोग से एपीआई को प्रॉक्सी करने के लिए grunt-connect-proxy "^ 0.2.0" का उपयोग कर रहा हूं। परियोजना योनि कोणीय जनरेटर के साथ शुरू की गई थी।ग्रंट कनेक्ट प्रॉक्सी: 404 नहीं मिला
मैं निर्देशों का पालन किया है here लेकिन जब प्रॉक्सी प्रयोग किया जाता है, मैं:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:9000/api/users
मेरे प्रॉक्सी कॉन्फ़िगरेशन:
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
proxies: [{
context: '/api', // the context of the data service
host: 'localhost', // wherever the data service is running
port: 8080, // the port that the data service is running on
https: false,
xforward: false
}],
मेरे मिडिलवेयर:
livereload: {
options: {
open: true,
base: '',
middleware: function (connect, options) {
var middlewares = [];
middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);
middlewares.push(connect.static('.tmp'));
middlewares.push(connect.static('test'));
middlewares.push(connect().use(
'/bower_components',
connect.static('./bower_components')
));
middlewares.push(connect.static(appConfig.app));
return middlewares;
}
}
},
मेरा काम
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer:server',
'configureProxies:server',
'connect:livereload',
'watch'
]);
});
संपादित स्थानीय होस्ट की सेवा: 8080/उपयोगकर्ताओं रिटर्न डाकिया के माध्यम से एक 403 वर्तमान में है, तो एपीआई चल रहा है।
क्या आपने सर्वर से प्रयास किया: {} विकल्प से पहले? –
इस प्रश्न पर एक नज़र डालें .. शायद यह https://stackoverflow.com/questions/34321143/adding-grunt-connect-proxy-to-generator-angular-gruntfile-js की मदद करेगा – aprok