blitz-js / blitz-js/blitz

Custom server not working from inside the `src` directory

Open
#3,999 2 comments 0 reactions 0 assignees View on GitHub
kind/bug status/ready-to-work-on
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### What is the problem?

Currently the blitz cli doesn't recognize a customer server file found in the `src` directory, but works when placed in the root.

### Where to update

`packages/blitz/src/cli/utils/next-utils.ts` needs to be updated:

```ts
export function getCustomServerPath() {
const projectRoot = getProjectRootSync()

let serverPath = path.resolve(path.join(projectRoot, "server.ts"))
if (existsSync(serverPath)) return serverPath

serverPath = path.resolve(path.join(projectRoot, "server.js"))
if (existsSync(serverPath)) return serverPath

serverPath = path.resolve(path.join(projectRoot, "server/index.ts"))
if (existsSync(serverPath)) return serverPath

serverPath = path.resolve(path.join(projectRoot, "server/index.js"))
if (existsSync(serverPath)) return serverPath

throw new Error("Unable to find custom server")
}
```

Contributor guide

Open the contributing guide

Research direction

Start in packages/blitz/src/cli/utils/next-utils.ts at getCustomServerPath(), comparing the project-root paths it checks with the reported src-directory case. Verify that a custom server located under src is recognized while existing root and server/index paths continue to work; the issue does not name a test file or command.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.