1

I am using Restify in my Heroku server. I am getting this error:

 XMLHttpRequest cannot load https://xxx.xxx.com/charging. Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://xxx.xxx.com' is therefore not allowed access.
The response had HTTP status code 405.

My Restify configuration is:

server
.use(restify.fullResponse())
.use(restify.bodyParser())
.use(restify.queryParser())
.use(restify.CORS({
    origins: ['https://xxx.xxx.com', 'http://xxx.xxx.com']
}));

What is missing in my configuration?

Burak
  • 5,706
  • 20
  • 70
  • 110

1 Answers1

1

In some cases, you may need to use server.pre instead of server.use.

https://github.com/restify/node-restify/issues/573

Mark Maruska
  • 1,210
  • 12
  • 13