lỗi access-control-allow-origin và cách khắc phục

tipjs,nodejs,express

lỗi access-control-allow-origin và cách khắc phục trong express, nodejs

app.all('*', function(req, res, next) {
  res.setHeader('Access-Control-Allow-Origin', '*')
  res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
  res.setHeader('Access-Control-Allow-Headers', 'Content-type,Accept,X-Access-Token,X-Key')
  if (req.method == 'OPTIONS') {
    res.status(200).end()
  } else {
    next()
  }
})

Có thể bạn đã miss một số snippets code

Kiểm tra định dạng email bằng Javascript

Kiểm tra định dạng email bằng Javascript

Đếm có bao nhiêu items giống nhau trong một array

reduce javascript. Đếm có bao nhiêu items giống nhau trong một array

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.

await axios get

await axios get

using Typescript callback style error handling