Note: API routes are still only supported in the pages folder, not app.
I was playing around with using API routes with the experimental app dir stuff in Next 13, and I was frustrated at having to use completely different code paths for accessing the request headers and cookies compared to in server components. So I hacked together a workaround which you definitely shouldn't use.
Usage requires two steps, one is easy, the other is invasive: