# trailingSlash: always is set, and passkey login says Not authenticated

> A login failure we reproduced locally. Why one extra trailing slash can break passkey login at the very first step, and how two curl commands tell you whether you are affected.

Source: https://emdashcmseverything.com/faq/emdash-cms-trailing-slash-passkey-login-faq/

- Published: 2026-11-10

## Why do we care about one slash?

Our own site runs a script after every build that checks whether each internal link ends with a trailing slash. This is not fussiness. An address without the slash gets a 308 redirect from the server first, and the search engine's webmaster tools log every one of those redirects as "Page with redirect" and report them to us one by one.

So when we read a community report saying someone could not log in with a passkey on their EmDash site, and that something in front of the site happened to append a slash to addresses, our first reaction was not sympathy. It was a guilty conscience: we could easily add that same setting ourselves, without thinking.

So we created a new blog-template site (EmDash 1.4.0, Node adapter, SQLite) and reproduced it.

## When login fails, which step is actually failing?

The first step of passkey login is that the page asks the server for a "challenge". The request goes to `/_emdash/api/auth/passkey/options`. The browser shows the fingerprint or security-key prompt only after this step succeeds.

We cannot make a script press a fingerprint sensor, so we tested only this step, using curl, with and without the trailing slash:

```bash
curl -i -X POST http://localhost:4400/_emdash/api/auth/passkey/options \
  -H 'X-EmDash-Request: 1' -H 'Content-Type: application/json' -d '{}'

curl -i -X POST http://localhost:4400/_emdash/api/auth/passkey/options/ \
  -H 'X-EmDash-Request: 1' -H 'Content-Type: application/json' -d '{}'
```

The first returns `200`, with a challenge and an `rpId`. The second differs by a single slash and returns:

```json
{"success":false,"error":{"code":"NOT_AUTHENTICATED","message":"Not authenticated"}}
```

`/_emdash/api/auth/mode` and `/_emdash/api/health` behave the same way: `200` without the slash, `401` with it.

One small detour is worth recording. We first requested `passkey/options` with a browser-style GET and got back a full HTML 404 page, and almost concluded the endpoint did not exist. It only accepts POST.

## Why 401 and not 404?

We read the source of EmDash's auth middleware. It contains a list of endpoints that can be reached without logging in, written in two forms: entries ending in `/` are matched as prefixes, and all the others are matched as exact strings. `passkey/options`, `passkey/verify`, `auth/mode` and `health` are all in the exact-match group.

Add one slash to the address and it no longer equals any entry on the list. The middleware then treats it as an ordinary endpoint that requires you to be logged in. And you are sending this request precisely because you are trying to log in.

The conclusion sounds like a riddle, but that is how it is: the first step of logging in is judged to require being logged in first.

## What if I really did set trailingSlash to always?

We tried that too. In `astro.config.mjs` we added:

```js
export default defineConfig({
  trailingSlash: "always",
  // ...
});
```

Then we tested the same endpoint:

| Request address | Result |
| --- | --- |
| `/_emdash/api/auth/passkey/options` | `404` |
| `/_emdash/api/auth/passkey/options/` | `401 NOT_AUTHENTICATED` |

Neither side works. We did not capture which form of address the admin page actually sends, so we cannot say which side it lands on, but whichever side it is, you cannot log in.

## What should I do now?

**First, set `trailingSlash` back to its default** (leaving it unset means `ignore`). We tested with the default: pages open with or without the slash, and the login endpoints work.

**Second, if the slash is added by your proxy or gateway**, let paths that start with `/_emdash/` through without rewriting them. We have not tried this on a real proxy. It follows from the principle above, so please verify it yourself.

**Third, about versions.** We tested 1.4.0. The corresponding fix has been merged into the main branch in the community, but when we tested, the latest release was still 1.4.0 and did not include it. So when you upgrade later, do not assume. Run the two curl commands above again. It takes ten seconds.

## Why does magic-link login still work?

That report mentioned that magic-link login kept working. Going by the list, this is not surprising: `auth/magic-link/` is an entry ending with a slash, so it is matched by prefix, and an extra trailing slash does not affect it. This is our inference from the list. We did not verify it separately.

## How do I tell whether I am affected?

Two things, and both must be true:

1. Passkey login reports `Not authenticated`, while magic-link login works.
2. In the curl test above, the address with the slash returns `401` and the address without it returns `200`.

If both return `200` in the second check, you have a different problem, and this article will not help.
