CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

fix localstorage bug when using datatables on with subdomains

Open madriegh opened this issue 3 years ago • 2 comments

We use Backpack on a project where the dev, staging and production environment are on different subdomains. Setting the e.g _list_url in localstorage with a key based only on the route caused redirects between our environments. The keys should include the subdomain path.

WHY

BEFORE - What was wrong? What was happening before this PR?

Install two project instances on subdomains, e.g. www.example.com/first and www.example.com/second

Create a CRUD panel with a list view and add filters.

Go to www.example.com/first/admin/your-crud Select a filter. You will see that the 'admin_yourcrud_list_url' key is set in localStorage to enable the persistent filters.

Go to www.example.com/second/admin/your-crud It will redirect back to the persisted url in the localStorage, which is www.example.com/first/admin/your-crud, the incorrect project.

AFTER - What is happening after this PR?

The keys are subdomain specific and don't interfere with each other anymore

HOW

How did you achieve that, in technical terms?

Took the full url as key prefix for the localStorage instead of solely the route

madriegh avatar Dec 15 '22 16:12 madriegh

The inspection completed: No new issues

scrutinizer-notifier avatar Dec 15 '22 16:12 scrutinizer-notifier

Thanks for the PR @madriegh . Never thought of testing two admin panels in one domain 😅

Seems like a reasonable quick solution to me! @pxpm what do you think? One thing I'm a bit bothered by is how ugly those entries will become... but... is that really relevant? 🤷‍♂️ What do you think?

tabacitu avatar May 17 '23 12:05 tabacitu