Jérémy
Jérémy
SSolidJS
Created by Jérémy on 8/10/2023 in #support
server$ API change in start 0.3.1 ?
I'm trying to update to last released solid-start 0.3.1 when I use server$ from an API route endpoint, I get this exception Server function called without a request context? Does this ring bells for some of you?
2 replies
SSolidJS
Created by Jérémy on 3/7/2023 in #support
Is there a way to hook into the router's match (client)?
Is there a way to hook into the router (client-side) to override router.location in the <Routes> component? I want to alter the matched route that I rewrote on the server using a middleware.
export const Routes = (props: RoutesProps) => {
const router = useRouter();
const parentRoute = useRoute();
const routeDefs = children(() => props.children) as unknown as () =>
| RouteDefinition
| RouteDefinition[];
const branches = createMemo(() =>
createBranches(routeDefs(), joinPaths(parentRoute.pattern, props.base || ""), Outlet)
);
const matches = createMemo(() => getRouteMatches(branches(), router.location.pathname));
//...
export const Routes = (props: RoutesProps) => {
const router = useRouter();
const parentRoute = useRoute();
const routeDefs = children(() => props.children) as unknown as () =>
| RouteDefinition
| RouteDefinition[];
const branches = createMemo(() =>
createBranches(routeDefs(), joinPaths(parentRoute.pattern, props.base || ""), Outlet)
);
const matches = createMemo(() => getRouteMatches(branches(), router.location.pathname));
//...
3 replies
SSolidJS
Created by Jérémy on 12/27/2022 in #support
Can I change the requested URL in a middleware?
I created a page middleware, and I'd like to update the requested URL from foo/bar to bim/bam/boum in the event object? Here's my skeleton code:
export const useBackendPathResolver = ({ forward }: MiddlewareInput) => {
return async (event: FetchEvent) => {

const pathname = new URL(event.request.url).pathname;
console.log("From middleware", pathname); // --> /foo/bar

// How can I change the requested URL?
// So that my route `routeData` func gets props.location == "/bim/bam/boum"

return forward(event);
};
};
export const useBackendPathResolver = ({ forward }: MiddlewareInput) => {
return async (event: FetchEvent) => {

const pathname = new URL(event.request.url).pathname;
console.log("From middleware", pathname); // --> /foo/bar

// How can I change the requested URL?
// So that my route `routeData` func gets props.location == "/bim/bam/boum"

return forward(event);
};
};
3 replies