jlarmstrongiv / astro-i18n-aut

The i18n integration for Astro 🧑‍🚀
https://www.npmjs.com/package/astro-i18n-aut
MIT License
125 stars 12 forks source link

npm run build error #9

Closed wanghaisheng closed 1 year ago

wanghaisheng commented 1 year ago

import { i18nMiddleware } from "astro-i18n-aut" import { sequence } from "astro/middleware"

const i18n = i18nMiddleware({ defaultLocale: "en" })

export const onRequest = sequence(i18n)

dubo@LAPTOP-I2R9VG58 MINGW64 /d/Download/audio-visual/saas/tiktoka/idea-to-action-cycle (main)
$ npm run build

> @example/minimal@0.0.1 build
> astro build

13:26:14 [astro-i18n-aut] exclude or remove non-astro files from "D:\Download\audio-visual\saas\tiktoka\idea-to-action-cycle\src\pages", as they cannot be translated
13:26:14 [astro-i18n-aut] D:\Download\audio-visual\saas\tiktoka\idea-to-action-cycle\src\pages\rss.xml.ts
13:26:14 [astro-i18n-aut] D:\Download\audio-visual\saas\tiktoka\idea-to-action-cycle\src\pages\open-graph\[...route].ts
13:26:18 [content] Types generated 2.57s
13:26:18 [build] output target: server
13:26:18 [build] deploy adapter: @astrojs/netlify/functions
13:26:18 [build] Collecting build info...
13:26:18 [build] Completed in 4.08s.
13:26:18 [build] Building server entrypoints...
13:26:52 [build] Completed in 33.83s.

 building client
Completed in 4.59s.

 prerendering static routes 
▶ src/pages/index.astro
[astro-icon] No sprites found while rendering "/"
  └─ /index.html (+409ms)
▶ src/pages/interaction-tools/index.astro
  └─ /interaction-tools/index.html (+86ms)
▶ src/pages/interaction-tools/[slug].astro
  └─ /interaction-tools/senior-software-engineer-open-source/index.html (+85ms)
▶ src/pages/wallpapers/index.astro
  └─ /wallpapers/index.html (+61ms)
▶ src/pages/resources/index.astro
  └─ /resources/index.html (+73ms)
▶ src/pages/showcase/[...page].astro
  └─ /showcase/index.html (+67ms)
▶ src/pages/toolkits/details/[slug].astro
  ├─ /toolkits/details/brand-social-influence-analyze/index.html (+93ms)
  ├─ /toolkits/details/brand-social-media-account-creation/index.html (+166ms)
  ├─ /toolkits/details/brand-tweets-monitor/index.html (+241ms)
  ├─ /toolkits/details/dump-brand-website-to-local/index.html (+324ms)
  ├─ /toolkits/details/grabstoreurls/index.html (+396ms)
  ├─ /toolkits/details/longtail-keywords-expand-tools-gui/index.html (+466ms)
  ├─ /toolkits/details/shopifystoredatabase/index.html (+539ms)
  └─ /toolkits/details/submit-url-to-search-engine/index.html (+610ms)
▶ src/pages/careers/index.astro
  └─ /careers/index.html (+51ms)
▶ src/pages/careers/[slug].astro
  └─ /careers/senior-software-engineer-open-source/index.html (+56ms)
▶ src/pages/themes/details/[slug].astro
  └─ /themes/details/tiny-rocket/index.html (+69ms)
▶ src/pages/videos/index.astro
  └─ /videos/index.html (+58ms)
▶ src/pages/about/index.astro
  └─ /about/index.html (+60ms)
▶ src/pages/blog/[slug].astro
  ├─ /blog/brand-building-components/index.html (+71ms)
  ├─ /blog/brand-monitor-task/index.html (+128ms)
  ├─ /blog/chatgpt-generated-slogn/index.html (+193ms)
  ├─ /blog/email-collecting-tool-for-brand/index.html (+251ms)
  ├─ /blog/how-can-chatgpt-aid-brand-monitoring/index.html (+306ms)
  ├─ /blog/how-to-use-google-tag-manager/index.html (+359ms)
  └─ /blog/product-message/index.html (+418ms)
▶ src/pages/blog/[...page].astro
  └─ /blog/index.html (+50ms)
▶ src/pages/404.astro
  └─ /404.html (+41ms)
λ src/pages/api/showcase.json.ts
13:27:01 [middleware] Using simple endpoints can cause unexpected issues in the chain of middleware functions.
It's strongly suggested to use full Response objects.
 error   Any data returned from middleware must be a valid `Response` object.
  File:
    D:\Download\audio-visual\saas\tiktoka\idea-to-action-cycle\node_modules\astro\dist\core\middleware\callMiddleware.js:25:17
  Code:
    24 |         if (value instanceof Response === false) {
    > 25 |           throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
         |                 ^
      26 |         }
      27 |         return value;
      28 |       } else {
  Stacktrace:
MiddlewareNotAResponse: Any data returned from middleware must be a valid `Response` object.     
    at file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/middleware/callMiddleware.js:25:17
    at async callMiddleware (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/middleware/callMiddleware.js:13:10)
    at async callEndpoint (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/endpoint/index.js:73:16)
    at async generatePath (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/generate.js:405:20)
    at async generatePage (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/generate.js:206:5)
    at async generatePages (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/generate.js:119:11)
    at async staticBuild (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/static-build.js:91:7)
    at async AstroBuilder.build (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/index.js:118:5)
    at async AstroBuilder.run (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/index.js:149:7)
    at async build (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/core/build/index.js:37:3)
    at async runCommand (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/cli/index.js:219:14)
    at async cli (file:///D:/Download/audio-visual/saas/tiktoka/idea-to-action-cycle/node_modules/astro/dist/cli/index.js:260:5)
wanghaisheng commented 1 year ago

File: D:\Download\audio-visual\saas\tiktoka\idea-to-action-cycle\node_modules\astro\dist\core\build\generate.js:279:10 Code: 278 | }

279 | return new AstroError({ | ^ 280 | ...AstroErrorData.InvalidDynamicRoute, 281 | message: invalidParam ? AstroErrorData.InvalidDynamicRoute.message( 282 | route.route, Stacktrace: InvalidDynamicRoute: The "slug" param for route /blog/[slug] is invalid. Received "en/brand-building-components".

jlarmstrongiv commented 1 year ago

According to the error for src/pages/api/showcase.json.ts:

[middleware] Using simple endpoints can cause unexpected issues in the chain of middleware functions. It's strongly suggested to use full Response objects.

You need to use a response object like https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes

return new Response(null, {
      status: 404,
      statusText: 'Not found'
    });

not an object:

return {
        body: JSON.stringify(result),
    }