Skip to content

Commit

Permalink
fix(planner/node.js): Wrong middleware function output
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaanlin committed Oct 14, 2023
1 parent bf396d2 commit 1c31b85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/nodejs/nextjs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func TransformServerless(image, workdir string) error {

fmt.Println("=> Building edge middleware")

err = buildMiddleware(tmpDir)
err = buildMiddleware(tmpDir, zeaburOutputDir)
if err != nil {
return fmt.Errorf("build middleware: %w", err)
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func writePrerenderConfig(zeaburOutputDir, r string) error {
return nil
}

func buildMiddleware(workdir string) error {
func buildMiddleware(workdir, zeaburOutputDir string) error {
files := []string{"middleware.js", "middleware.ts", "src/middleware.js", "src/middleware.ts"}
var middlewareFile string
for _, file := range files {
Expand All @@ -342,7 +342,7 @@ func buildMiddleware(workdir string) error {
return fmt.Errorf("esbuild run failed")
}

wp := path.Join(workdir, ".zeabur/output/functions/_middleware.func/index.js")
wp := path.Join(zeaburOutputDir, "functions/_middleware.func/index.js")
_ = os.MkdirAll(path.Dir(wp), 0755)
err := os.WriteFile(wp, res.OutputFiles[0].Contents, 0644)
if err != nil {
Expand Down

0 comments on commit 1c31b85

Please sign in to comment.