0

I'm trying to develop an updatable apple wallet pass, I've put it a webserviceURL and a authenticationToken, I'm trying to test the registration using a local server through ngrok (ngrok http portNumber),

I am able to sign the pass and install the pass onto my physical iPhone.

My API endpoint "https://ngrokexmaple-ngrok.io/passes" is receiving the post request from the wallet will all the passTypeID and serialNumbers that I defined in the headers and the params.

However, when looking at the post request using req.body, it returns undefined and I am unable to move on to testing the actually updating of the pass.

const express = require("express");
const app = express();
app.route(
  "/pass/:version/devices/:deviceLibraryIdentifier/registrations/:passTypeIdentifier/:serialNumber"
      )
      .post(async (req, res) => {
        console.log("here! registration");
        console.log("PARAMS", req.params);
        console.log("HEADERS", req.headers);
        console.log("BODY", req.body);
        console.log(Object.keys(req));
        res.send("ok");
      });

When console logging the request I get the following:

here! registration
PARAMS {
  version: 'v1',
  deviceLibraryIdentifier: '<deviceLibraryIdentifier>',
  passTypeIdentifier: '<passTypeIdentifier>',
  serialNumber: '<serialNumber>'
}
HEADERS {
  host: '760b-59-152-218-142.ngrok.io',
  'user-agent': 'passd/1.0 CFNetwork/1333.0.4 Darwin/21.5.0',
  'content-length': '80',
  accept: '*/*',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'en-GB,en;q=0.9',
  authorization: 'ApplePass <authorizationToken>',
  'content-type': 'application/json',
  'x-forwarded-for': '14.0.224.6',
  'x-forwarded-proto': 'https'
}
BODY undefined

I tried debugging using the logs however the result in the same as the JSON payload cannot be accessed. Is there anything wrong with the way I'm approaching the registration? any help would be hugely appreciated

Jason Lee
  • 11
  • 2
  • Welcome to StackOverflow! You need a body-parsing middleware before your `async (req, res) {...}` function. For example, if the body shall contain JSON, use [`express.json()`](http://expressjs.com/en/4x/api.html#express.json). – Heiko Theißen Jul 15 '22 at 08:21
  • @HeikoTheißen, didn't know know I needed a body parser, thanks so much for helping me out! – Jason Lee Jul 15 '22 at 08:31

0 Answers0