Nuxt.jsのSSRでFileオブジェクトを使用したいのですが、サーバーサイドでは読み込みできないようで、File is not defined
のエラーになってしまいます。
https://github.com/spatie/form-backend-validation/issues/74
こちらのイシューを見て、nuxt.config.jsに下記のコードを追加すればいいことが分かったのですが、その記述方法が分かりません。
global.File= typeof window === 'undefined' ? Object : window.File global.FileList= typeof window === 'undefined' ? Object : window.FileList
そのままコピペするとError: ParseError: Unexpected token, expected ","
のエラーでビルドできません。
以下の方法を試してみましたが、File is not defined
が解消できませんでした。
global: { File: typeof window === 'undefined' ? Object : window.File, FileList: typeof window === 'undefined' ? Object : window.FileList, },
publicRuntimeConfig: { File: typeof window === 'undefined' ? Object : window.File, FileList: typeof window === 'undefined' ? Object : window.FileList, },
SSRでFileオブジェクトを使用する方法、またはnuxt.config.jsの記述方法をどなたかご教授いただけないでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。