Secured Cron Job for Google App Engine fails to start (Node js)

Viewed 1151

I am struggling with a cron job with secured URL in google app engine. As soon as I add login:admin in the app.yaml, the job fails to start (otherwise it works like a charm).

Here is my code:

  • app.js

    const express = require('express');
    const app = express();
    
    app.get('/', (req, res) => {
      res.status(200).send('Hello, world!').end();
    });
    
    app.get('/admin', function(req, res){
     res.status(200).send('Hello, admin!').end();
    });
    
    
    // Start the server
    const PORT = process.env.PORT || 8080;
    app.listen(PORT, () => {
      console.log(`App listening on port ${PORT}`);
      console.log('Press Ctrl+C to quit.');
    });

  • app.yaml

    runtime: nodejs
    env: flex
    
    handlers:
    - url: /
      script: app.js
      
    - url: /admin
      login: admin
      script: app.js

  • cron.yaml

    cron:
    - description: daily summary job
      url: /admin
      schedule: every 12 mins
      target: default

And the result: cron failure

Any hint on what I am missing?

Thanks a lot in advance

1 Answers
Related