Ganesh
Ganesh

Reputation: 266

Swagger file hosting using Node js

I created a node js service for my peoject.

My requirement is by typing "SERVICEURL/help", swagger file should be loaded and the same should be hosted to Azure.

But not able to achieve the requirement.

Is the requirement is valid and achievable, if yes, help me in this.

Thanks in advance.

Upvotes: 0

Views: 111

Answers (1)

Aaron Chen
Aaron Chen

Reputation: 9950

To achieve your requirement, you can try the following,

app.get('/help', function (request, response) {

  response.writeHead(301,
    {Location: 'http://yoursitename.azurewebsites.net/swagger'}
  );
  response.end();
})

If you are using Express framework, you can also do the same thing with the code below,

app.get('/help', function (req, res) {
  res.redirect('http://yoursitename.azurewebsites.net/swagger');
})

Upvotes: 1

Related Questions