Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ローカルでyarn devしてブログ一覧を開くとInvalid request URLエラー #71

Closed
otoyo opened this issue Feb 25, 2023 · 10 comments · Fixed by #72
Closed

ローカルでyarn devしてブログ一覧を開くとInvalid request URLエラー #71

otoyo opened this issue Feb 25, 2023 · 10 comments · Fixed by #72

Comments

@otoyo
Copy link
Owner

otoyo commented Feb 25, 2023

image

OSはmacOS, Windows共に発生。
再現性はなし→再現した

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

デバッグ

  1. node_modules/@notionhq/client/build/src/Client.js に下記を追加
    L339
  try {
+     console.log(url.toString())
      const response = ...
  1. yarn dev して /blog を開く
  2. yarn dev したターミナルに出力されたURLが正しいかどうか確認

URLは https://api.notion.com/v1/databases/c92f540ccb694c83aed7f890c27fcd5d/query のようになっているはず。

@okash1n
Copy link

okash1n commented Feb 25, 2023

先程初めて使わせていただきました。 .evn には NOTION_API_SECRET および DATABASE_ID を記載しましたが、Invalid request URL になります。

なお、Cloudflare側では問題なく表示されました。

環境はWin11、WSLです。

Cloudflareとローカルの差分は

Cloudflare: NODE_VERSION v16.13.0
ローカル: NODE_VERSION v19.2.0

だったのでそれかもしれません。ローカルのnodeのバージョン変えてリトライしてみようかと思います

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

@okash1n 情報ありがとうございます。引き続き調査進めます。

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

image

DATABASE_IDが入るところが空になっていることがわかった。

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

.env を使用したところ再現した。
.env の内容が yarn dev で反映されてないのかもしれない。

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

#72 で修正

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

#72 で修正したので同じ症状の方取り込んで試していただけますと幸いです。

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

原因

0.3.0でNOTION_API_SECRETなどの環境変数の読み込みを process.env 経由に変更したが、.env に書かれた環境変数は import.meta.env 経由でしか読み込めなかった。
https://docs.astro.build/ja/guides/environment-variables/

自身は .env を使っていなかったため最初再現しなかった。

@otoyo otoyo closed this as completed in #72 Feb 25, 2023
@okash1n
Copy link

okash1n commented Feb 25, 2023

取り込んで問題なく表示されました!

@otoyo
Copy link
Owner Author

otoyo commented Feb 25, 2023

ご報告ありがとうございます!よかったです!

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 a pull request may close this issue.

2 participants