#Got error Uncaught Error parameter is required on Cloudflare pages

2 messages · Page 1 of 1 (latest)

maiden depot
#

I try to deploy an Astro blog with microCMS(https://microcms.io/ ) on Cloudflare Pages(https://pages.cloudflare.com/ ).
Source code:
https://github.com/excelsior091224/new_blog
But this error occurred every time and failed.

20:22:52.334    Deploying your site to Cloudflare's global network...
20:22:56.447     Uploading... (7/7)
20:22:56.448    
20:22:56.451    :sparkles: Success! Uploaded 0 files (7 already uploaded) (0.56 sec)
20:22:56.451    
20:22:56.872    :sparkles: Upload complete!
20:22:58.220    Success: Assets published!
20:22:58.797    Error: Failed to publish your Function. Got error: Uncaught Error: parameter is required (check serviceDomain and apiKey)
  at worker.mjs:14:27454 in Do
  at worker.mjs:447:1263

In this error message, it seems can’t read serviceDomain and apiKey which set in blow file.

import { createClient, MicroCMSQueries } from "microcms-js-sdk";
console.log(import.meta.env.MICROCMS_API_KEY);
console.log(import.meta.env.MICROCMS_SERVICE_DOMAIN);
const client = createClient({
  serviceDomain: import.meta.env.MICROCMS_SERVICE_DOMAIN,
  apiKey: import.meta.env.MICROCMS_API_KEY,
});

export type Blog = {
  id: string;
  createdAt: string;
  updatedAt: string;
  publishedAt: string;
  revisedAt: string;
  title: string;
  content: string;
  eyecatch: {
    url: string;
    height: number;
    width: number;
  };
};
export type BlogResponse = {
  totalCount: number;
  offset: number;
  limit: number;
  contents: Blog[];
};

export const getBlogs = async (queries?: MicroCMSQueries) => {
  return await client.get<BlogResponse>({ endpoint: "blogs", queries });
};
export const getBlogDetail = async (
  contentId: string,
  queries?: MicroCMSQueries
) => {
  return await client.getListDetail<Blog>({
    endpoint: "blogs",
    contentId,
    queries,
  });
};

https://github.com/excelsior091224/new_blog/blob/main/src/library/microcms.ts
But I set environment variables in setting.
Any ideas? Thanks.

microCMS|APIベースの日本製ヘッドレスCMS

microCMSはAPIベースの日本製のヘッドレスCMSです。もう社内向け編集/管理画面を自作する必要はありません。開発・運用コストを大きく下げることでビジネスを加速させます。

Build your next application with Cloudflare Pages

GitHub

Contribute to excelsior091224/new_blog development by creating an account on GitHub.

GitHub

Contribute to excelsior091224/new_blog development by creating an account on GitHub.

maiden depot
#

Got error Uncaught Error parameter is required on Cloudflare pages