Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side single maps - cookie should specify a path #68

Open
jaydgruber opened this issue Jun 14, 2022 · 1 comment
Open

Server-side single maps - cookie should specify a path #68

jaydgruber opened this issue Jun 14, 2022 · 1 comment

Comments

@jaydgruber
Copy link

jaydgruber commented Jun 14, 2022

What

  • when using server-side-single-map, using the overrides UI on multiple routes can cause overrides persist in cookies even after they have been deleted in the UI.
// server.js 

// ExpressJS middleware - used on each route that requests a document w/ import-map-overrides
const importMapOverridesMiddleware = (req, res, next) => {
  const overrides = importMapOverrides.getOverridesFromCookies(req);
  if (Object.keys(overrides).length === 0) {
    app.locals.importMap = app.locals.originalImportMap;
  } else {
    app.locals.importMap = new Map([...app.locals.originalImportMap, ...Object.entries(overrides)]);
  }
  next();
};

Scenario

  • visit page http://localhost:8080
  • using overrides UI, add a new override: "elephant": "https://ci.assets.avalara.com/one-web-domain/elephant/0.0.0%2b8a086bcf"
    • confirm localStorage gets a new entry as expected import-map-override:elephant
    • confirm new cookie created as expected: import-map-override:elephant:"https://ci.assets.avalara.com/one-web-domain/elephant/0.0.0%2b8a086bcf"
  • visit page http://localhost:8080/elephant
  • using overrides UI, "Reset all overrides"
    • confirm localStorage entry import-map-override:elephant has been deleted
    • cookie is not deleted as expected
  • using overrides UI, add a new override (same value)
    • now I have two cookies w/ same name and value, one on path=/, one on path=/elephant
  • navigate back to http://localhost:8080
  • using overrides UI, "Reset all overrides"

Proposed solution

@Matt0911
Copy link

Matt0911 commented Dec 2, 2022

I am also using server-side-single-map and am impacted by a sub-issue of this. Bullet 4, reset all overrides cookie is not deleted. If you reset an individual override, the cookie is deleted. However when disabling any individual override, the cookie is also not deleted. This causes inconsistencies between the UI state and the import map returned by the server.

Disabling should have the same end result as removing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants