Unable to use some response function #34

Closed
opened 2020-03-18 02:01:51 +00:00 by Ghost · 1 comment

I'm trying to migrate my app to serve by greenlock-express.js recently, but I get some errors that never happened in original express app:

  1. res.status(403)
    Error: TypeError: res.status is not a function
    Resolved by updating the code to res.statusCode = 403.

  2. res.json({ ... })
    Error: TypeError: res.json is not a function
    Resolved by updating the code to:

res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(data))

Here's my greenlock-express app:

greenlockExpress
  .init(options)
  .serve(glx => {
    glx.serveApp((req, res) => { ... })
  })

Did I missed anything?
It's kind of inconvenient that I can't use the functions above and it makes the code longer.

I'm trying to migrate my app to serve by greenlock-express.js recently, but I get some errors that never happened in original express app: 1. `res.status(403)` Error: `TypeError: res.status is not a function` Resolved by updating the code to `res.statusCode = 403`. 2. `res.json({ ... })` Error: `TypeError: res.json is not a function` Resolved by updating the code to: ``` res.setHeader('Content-Type', 'application/json') res.end(JSON.stringify(data)) ``` Here's my greenlock-express app: ``` greenlockExpress .init(options) .serve(glx => { glx.serveApp((req, res) => { ... }) }) ``` Did I missed anything? It's kind of inconvenient that I can't use the functions above and it makes the code longer.
Owner

you still need to require express and create an app.

greenlock only handles the security-related bits, nothing else.

you still need to require `express` and create an app. greenlock only handles the security-related bits, nothing else.
Ghost closed this issue 2020-03-19 06:41:08 +00:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: root/greenlock-express.js#34
No description provided.