zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
998 stars 122 forks source link

Switch from `?` url search to hash for code parameter due to backend URL length limits #121

Closed Billiam closed 2 years ago

Billiam commented 2 years ago

I'm honestly not sure how I feel about this, but here's the PR anyway.

Github pages appears to have a URL parameter length (or possibly data) limit, causing 503 errors when trying to load the project from URL again. For my project, it's failing with a code parameter that's about 7300 characters (about 600 lines of actual code / 23k characters).

This PR switches to using #code=... instead, so the code data is never passed to nginx/unicorn. The ?code=... param is still allowed, but will switch the URL history push over to #code=... after the first code change.

with search param

with hash param

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/zalo/cascade-studio/EaWe2Uq7q5JoL9GpNEQPG1hxGLur
âś… Preview: https://cascade-studio-git-fork-billiam-feature-hash-url-param-zalo.vercel.app

zalo commented 2 years ago

Thank you for the PR!

I see some vestigial gallery code is getting removed; fair enough. I appreciate you maintaining backward compatibility.

What are the drawbacks? Would it make sense to only activate this mode if the encoded URL is longer than some limit?

(Also, your example file latching box is awesome!)

P.S. Don’t be afraid to @ me in new PRs if it seems I’m not seeing them, GitHub sometimes acts silly about notifications…

Billiam commented 2 years ago

I see some vestigial gallery code is getting removed; fair enough. I appreciate you maintaining backward compatibility.

I wasn't clear what the state of that was. It's easy to leave it in too!

What are the drawbacks? Would it make sense to only activate this mode if the encoded URL is longer than some limit?

The one I was thinking of is just compatibility. Even if it's backwards compatible, if there are other tools depending on the search param perhaps?

zalo commented 2 years ago

What are the drawbacks? Would it make sense to only activate this mode if the encoded URL is longer than some limit?

The one I was thinking of is just compatibility. Even if it's backwards compatible, if there are other tools depending on the search param perhaps?

@Irev-Dev would having CascadeStudio switch to using #'s instead of ?'s needlessly break old versions of CadHub that might be floating around out there? (I'd suspect not if it used a forked IDE...)

Otherwise, I can't think of a system that relies on having ? query parameters... Maybe the QR Code Library wouldn't like it?

Irev-Dev commented 2 years ago

All good from me @zalo, I had disabled the encoded urls anyway (since cadhub has user accounts etc to just save projects)

zalo commented 2 years ago

Alright, well, let's see what breaks then!