firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

Add configurable Cloud Function ignores to allow for tooling like next-i18next, prisma, etc. in web frameworks #5607

Open nidegen opened 1 year ago

nidegen commented 1 year ago

Environment info

firebase-tools: 11.24.1

Platform: macOS 13.1

Test case

Web-i18n.zip

Steps to reproduce

Run firebase deploy and go to <host>/invite/random-id.

Expected behavior

One receives a page that encodes the current URL in a QR code.

Actual behavior

One gets a 500 error. In the logs this looks like:

Error: next-i18next was unable to find a user config at /workspace/next-i18next.config.js
    at _callee$ (/workspace/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:104:19)
    at tryCatch (/workspace/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
    at Generator.<anonymous> (/workspace/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
    at Generator.next (/workspace/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21)
    at asyncGeneratorStep (/workspace/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/workspace/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
    at /workspace/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
    at new Promise (<anonymous>)
    at /workspace/node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12
    at serverSideTranslations (/workspace/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:168:17)

Some further info as how I tried to fix it unsuccessfully so far can be found here.

jamesdaniels commented 1 year ago

So the root cause here, is that out of box we only include the compiled nextjs application when we build the Cloud Function. We need a way to allow you to override the "ignores" in the code-generated Cloud Function. I expect it would look something like firebase.json hosting.frameworksBackend.ignore = ['node_modules', ...]

nidegen commented 1 year ago

That sounds good!

nidegen commented 1 year ago

Is this expected to be fixed or do I need to file a bug report or so? Maybe I can also make a PR.

nidegen commented 1 year ago

Ping?😅

nidegen commented 1 year ago

Fixed in https://github.com/firebase/firebase-tools/pull/5788 I guess :)

nidegen commented 1 year ago

Hmm, that was too quick. I still get errors for server-side rendered content :(

jamesdaniels commented 1 year ago

Yeah, we still need an explicit ignores override for the Cloud Function.

ENT108 commented 11 months ago

I am facing the very same issue trying to host nextjs app with next-i18next... is there any way the hosting to actually find this file?

amit-meena commented 11 months ago

I am also getting this error: Error: next-i18next was unable to find a user config at /workspace/next-i18next.config.js Please update if this will be fixed soon, or any workaround is available. Thanks

redcomethk commented 11 months ago

Not sure if this should be considered as a workaround... We changed the project to deploy to Google App Engine and seems the nextjs app works after that.

ENT108 commented 11 months ago

We changed the project to deploy to Google App Engine and seems the nextjs app works after that.

nextjs hosting works in general, but its not working if you configure nextjs recommended internationalization (next-i18next). It actually blocks my company webpage to go multilingual.

ENT108 commented 11 months ago

Is there any way I can add files to hosting root manually?

nidegen commented 11 months ago

So @alexastrum, how is it going;)

nidegen commented 11 months ago

BTW: @mathantunes showed me a workaround by copying next-i18mext.config.js to /public and registering into an .env fiel as

I18NEXT_DEFAULT_CONFIG_PATH="./public/next-i18next.config.js"
ENT108 commented 8 months ago

BTW: @mathantunes showed me a workaround by copying next-i18mext.config.js to /public and registering into an .env fiel as

I18NEXT_DEFAULT_CONFIG_PATH="./public/next-i18next.config.js"

Yeah, thanks for that!