Skip to content

Commit

Permalink
- Fixing minor routing issue with trailing slashes not being present
Browse files Browse the repository at this point in the history
  • Loading branch information
incutonez committed Nov 14, 2024
1 parent 8595b2c commit 65b70a9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Binary file modified api/src/db/data.db
Binary file not shown.
8 changes: 8 additions & 0 deletions ecommerce/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ declare module "@tanstack/react-router" {

const router = createRouter({
routeTree,
/**
* We want this because we want to be able to reuse our route string constants in routes.ts... if we didn't do this,
* then the route generation has a mix of keys with trailing slash, but the path of the route wouldn't have the slash.
* When we specify always, it will always require a trailing slash in our URLS. The default is never, which would
* strip out the trailing slash, if we provided it, which would cause issues for routes that have it. When it gets
* stripped out, and we're dealing with an index file, then it assumes params are required
*/
trailingSlash: "always",
history: createHashHistory(),
});

Expand Down
2 changes: 1 addition & 1 deletion ecommerce/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const RouteViewProducts = "/products/";

export const RouteViewProduct = `${RouteViewProducts}$productId`;

export const RouteViewCart = "/cart";
export const RouteViewCart = "/cart/";
File renamed without changes.

0 comments on commit 65b70a9

Please sign in to comment.