Skip to content

Can't add other services to the same app after initialization of express-user-manager #4

@antonioleoreply

Description

@antonioleoreply

If I try to add other methods to the same app used by the module I receive this error:

(node:41104) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (internal/errors.js:322:7)
    at ServerResponse.setHeader (_http_outgoing.js:561:11)
    at ServerResponse.header (C:\Repositories\Obiwan\rona_core_tools\node_modules\express\lib\response.js:771:10)
    at ServerResponse.send (C:\Repositories\Obiwan\rona_core_tools\node_modules\express\lib\response.js:170:12)
    at ServerResponse.json (C:\Repositories\Obiwan\rona_core_tools\node_modules\express\lib\response.js:267:15)
    at login (C:\Repositories\Obiwan\rona_core_tools\server\express-user-manager\routes\handlers\login.js:81:30)

my code:

app.use(
  fileUpload({
    createParentPath: true,
  }),
)
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(morgan('dev'))
app.use(express.static(path.join(__dirname, '../build')))

const dbAdapter = 'mongoose'
const store = userManager.getDbAdapter(dbAdapter)
userManager.listen(app, (apiMountPoint = '/rest/users'), (customRoutes = {}))

app.get('/examplerequest', function (req, res) {
  res.send('example response')
})

store.connect(Mongo.mongoURI).then(() => {
  server.listen(port, () => {
    console.log(`Server running at http://localhost:${port}/`)
  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions