'Access-Control-Allow-Origin' header is present on the requested resource

  • nodejs
app.use(function(req, res, next) {
       next(createError(404));
});        #기존  소스를 아래와 같이 변경

app.use(function(req, res, next) {
        res.header("Access-Control-Allow-Origin", "*");
        res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
        res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
        next();
});