App infinitely reloading and not sure why.
In my Astro app i am using a simple middleware following the example in the docs and for some reason when i am on my root page it infinitely reloads the page, the issue seems to be happening when calling:
my whole middleware:
could be my api routes doing something weird but i wouldn't have though so
Solution:Jump to solution
I am was able to figure this out, when we try and auth a request we send it to
/api/auth/*
to get the session however the middleware will run on this meaning we will end up in an infinite loop due to it calling itself over and over again, not a problem on certain pages but possibly on others. my reworked middleware.ts
```ts
import { auth } from "@/lib/server/auth";
import { defineMiddleware } from "astro:middleware";
...1 Reply
Solution
I am was able to figure this out, when we try and auth a request we send it to
/api/auth/*
to get the session however the middleware will run on this meaning we will end up in an infinite loop due to it calling itself over and over again, not a problem on certain pages but possibly on others. my reworked middleware.ts