Unable to route on DID

I’ve previously had an Asterisk installation running for about 3 years without problem (though it may have used Chan_SIP rather than PJSIP). It supported 2 phone numbers at the provider. Following a major failure I’ve reinstalled from scratch which ought to have been straightforward. However though I can get phone calls in and out I cannot route based on the DID. The To field being used for processing appears not to contain the dialled number, whereas the number is present in other headers.

The following is in at least one logged header:
178796To: sip:02xxxxx7568@voiceless.aa.net.uk

However by the time from-pstn-toheader is called the header to field looks like:
178829To: sip:s@

Suggestions as to where to look would be welcome.

What’s that. GitHub says:

repo:asterisk/asterisk from-pstn-toheader

Your search did not match any code

Ask on https://community.freepbx.org/ although you might want to note chan_pjsip uses s as the default value for contact-user, although that would mean you weren’t receiving the value from the provider, but only one reflected, by the provider, from you sent it. To the extent that contact-user is just reflected back, you could set your initial extension to be s. Maybe FreePBX calls the initial extension, for incoming calls, the DID?

repo:FreePBX/core from-pstn-toheader

does produce a hit.

Thank you for the reference to the freepbx community. There are many references to DID not working though most appear to have been solved by using the from-pstn-toheader context. I’ll do some more digging and debugging to see where the correct DID gets replaced by s.