Skip to content

fix(cli): generate index handler for root routes - #1048

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
niteshseram:fix/route-gen
Dec 6, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
niteshseram:fix/route-gen

Conversation

@niteshseram

@niteshseram niteshseram commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

void gen route / reported success and wrote routes/.ts. Stripping the leading slash leaves an empty filename stem, so the generated file is skipped by route discovery and GET / returns 404 in an app without a homepage.

Use index as the filename stem for the root route so the command generates routes/index.ts.

Follow-up question: page and handler at /

With both pages/index.tsx and routes/index.ts present, the route file's GET handler takes precedence. Currently, opening / returned the handler's JSON even with Accept: text/html. Moving the handler aside made / render the homepage.

This means running void gen route / in an app with an existing homepage can replace the HTML response at / with the generated JSON response. Should we keep that precedence, or should Void report the conflict when a page and a handler both claim GET /? If the precedence is intentional, should the generator warn before scaffolding the handler?

For comparison, the Next.js App Router reports a conflict when page.tsx and route.ts resolve to the same URL

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's keep the existing precedence.

@cpojer
cpojer merged commit c48bd45 into voidzero-dev:main Dec 6, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants