I need to add a /.well-known
directory to my site with a JSON file in it, for an external service to verify that I own the domain.
I have tried adding a public/.well-known
directory to my source repository, which does make the necessary file appear at the right location. However, this seems to be behind a 308 redirect, and the external service does not accept this as a valid HTTP response code. For example:
curl -X HEAD -i 'https://[redacted].com/.well-known/microsoft-identity-association.json'
[...]
HTTP/2 308
cache-control: public, max-age=0, must-revalidate
content-type: text/plain
date: Tue, 14 Jan 2025 18:57:40 GMT
location: https://www.[redacted].com/.well-known/microsoft-identity-association.json
refresh: 0;url=https://www.[redacted].com/.well-known/microsoft-identity-association.json
server: Vercel
strict-transport-security: max-age=63072000
And Microsoft’s domain verification returns the following error message: “Verification of publisher domain failed. Request returned the wrong HTTP status code. Expected: OK, Actual: 308.”
I tried searching the Vercel docs and got a recommendation to add the following to my vercel.json
file, but this did not make any difference:
"routes": [
{
"src": "/.well-known/(.*)",
"dest": "public/.well-known/$1"
}
]
How can I make a file appear in a /.well-known
directory without any 308 redirect?