Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http request not working in node file after hosting in IIS with the help of IISnode and rewrite #549

Open
vinuuu opened this issue Dec 10, 2016 · 2 comments

Comments

@vinuuu
Copy link

vinuuu commented Dec 10, 2016

Node.js

var express = require('express');
var app = express.createServer();
var path = require('path');
var AWS = require('aws-sdk');
var bodyParser = require('body-parser');

var multiparty = require('connect-multiparty'),
multipartyMiddleware = multiparty();

app.use(express.static(path.join(__dirname)));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/',routes);

app.use(function(req, res, next) { //allow cross origin requests
res.setHeader("Access-Control-Allow-Methods", "POST, PUT, OPTIONS, DELETE, GET");
res.header("Access-Control-Allow-Origin", "IP");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

app.get('/', function(req, res){
res.sendfile('index.html', { root: __dirname + "/" }) ;
res.end();
});

app.post('/myapp/photoUplad', multipartyMiddleware, function(req, res) {
console.log(app.BucketName);
console.log(req.body);
console.log('-------------------');
console.log(req.files.file);

var file = req.files.file;

var fs = require('fs');
var fileStream = fs.createReadStream(file.path);
fileStream.on('error', function(err) {
    console.log('File Error', err);
});
uploadParams.Body = fileStream;

var path = require('path');

// call S3 to retrieve upload file to specified bucket
s3.upload(uploadParams, function(err, data) {
    if (err) {
        console.log("Error", err);
    }
    if (data) {
        console.log("Upload Success", data.Location);
    }
});
res.end();

});

Angular controller
http.post('/myapp/photoUplad', JSON.stringify({ keyname: keynameq })).then(function(data) {

    });

Web.config

<!-- indicates that the hello.js file is a node.js application 
to be handled by the iisnode module -->

<handlers>
  <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>

 <rewrite>
  <rules>
   <clear />
    <rule name="cdw">
      <match url="/myapp/photoUplad" />
       <action type="Rewrite" url="app.js" />
    </rule>
  </rules>
</rewrite>

NOTE :404 Error any help on this

@vinuuu
Copy link
Author

vinuuu commented Dec 10, 2016

@tjanczuk Please respond on this

@vinuuu
Copy link
Author

vinuuu commented Dec 13, 2016

@dupuis2387 ..hi can u delete comment for god sake..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant