micro-cors: Error with microrouter

My code:

import micro from 'micro'
import auth from './auth'
import routes from './routes'
import cors from 'micro-cors'

micro(cors(auth(routes))).listen(3000)

then I get

TypeError: "string" must be a string, Buffer, or ArrayBuffer
    at Function.byteLength (buffer.js:441:11)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I use microrouter and micro-cors in my apis, here’s how I do it:

const cors = require('micro-cors')()
const { router, get, post } = require('microrouter')

const { getItems, getItem, createItem } = require('./handlers')

module.exports = cors(router(
  get('/', getItems)
  get('/:id', getItem),
  post('/', createItem)
))

use const cors = require('micro-cors')()

It is important to include ()