Configure /studio/index.html to handle requests to /studio/*

- https://mysiek-pl.pages.dev (users should access from https://mysiek.pl) - Deployment ID: a1e49976-0fb4-4d4b-969d-0acd72e37e57 - Account ID: 5f2dea697c8022bf9f348c2dba9433b2 I'm using Cloudflare pages to host a static website built with Astro. It's integrated with Sanity.io CMS system - this integration exposes a React SPA on URLs beginning with /studio/. This SPA works fine, but if you refresh the page, client is redirected to 404 error page. I've already tried the following _redirects file, unfortunately to no avail:
/studio/* /studio/index.html 200
/studio/* /studio/index.html 200
I'd like to point out that it was correctly placed in my public folder, I noticed that it was detected by Cloudflare in deployment details. I had also set up a Transform Rule earlier, but it has only caused Too many redirects error. I had used the following settings:
Request URL: https://mysiek.pl/* (I also tried https://mysiek.pl/studio/*)
Target path: /studio/*
Rewrite to: /studio/index.html
Request URL: https://mysiek.pl/* (I also tried https://mysiek.pl/studio/*)
Target path: /studio/*
Rewrite to: /studio/index.html
Please help me set this up, because the current situation isn't very comfortable for editors who need to access the Sanity Studio.
4 Replies
MrSteel
MrSteel•3w ago
It seems to me the rules you have setup somehow run in an infinite loop. How about adding to the redirects a rule that excludes /studio/index.html. And no redirects file. Just a thought 🙂
Dewidos
DewidosOP•3w ago
But isn't rewrite supposed to point the request differently internally? Why is browser getting HTTP 308 and showing this error I've managed to remove the loop, but it just redirects to studio's root now
Dewidos
DewidosOP•3w ago
No description
Dewidos
DewidosOP•3w ago
Preferably I'd like the path to be handled by /studio/index.html, but still be left the same so the SPA sees the path from user's browser. Does anybody know how to set this up? Thank you very much, it worked like a charm. I'm very grateful.
Want results from more Discord servers?
Add your server