Stop fixing, start diagnosing. Prompt:
Don't change any code. List 3 possible causes for this, and for each one a way to check it (a log, a URL to open, a value to print).
Then you check them. Loops happen when the model assumes cause A and the real cause is something it can't see (env var, dashboard setting, a redirect URL). Asking for hypotheses gets it out of "patch mode".
Also: after 3 failed rounds, new conversation with a short summary of what was tried. Round 8 in the same context is mostly the model repeating its own earlier answers.