3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nuxt.jsでgenerateした静的サイトではnuxt/axiosのproxy機能は使用できない

Posted at

※指摘大歓迎!

背景

  • SPA など静的サイトとしてデプロイし、外部の API を実行する。
  • nuxt.js で開発する際、CORS 対応として nuxt/axios の proxy 機能を使用する回避策が良く見つかる。
  • yarn dev などでローカルサーバを起動して動作確認する場合には問題ない。
  • yarn generate などでビルドした成果物を Web サイトとしてデプロイすると proxy が機能しない。

原因

回避策

  • proxy 機能を使用しない
  • nuxt.config.js の axios 設定に baseURL を指定するのが便利
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?