Coder Social home page Coder Social logo

Comments (19)

sarovin avatar sarovin commented on May 19, 2024 3

When using

"serve": "firebase serve --port 5000 --only functions,hosting"

you must wait this line:

i  hosting: Serving hosting files from: build/public
✔  hosting: Local server: http://localhost:5000

✔  functions: next: http://localhost:5001/<Project-name>/us-central1/next

Node: v7.4.0
Yarn: 0.27.5

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024 1

Solved it! Try this:

"serve": "firebase serve --port 5000 --only hosting"

instead of:

"serve": "firebase serve --port 5000 --only hosting,functions"

I noticed that when I used "serve": "firebase serve" the console output did say anything about functions.
yarn serve 03

It seems that the rewrite rule in firebase.json does everything required to host the functions without us needing to specify anything.

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024 1

See this repo => https://github.com/Bolket/next-firebase-functions/tree/development

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024 1

I like what you did including ES6+ transpiling with the nice folder structure too. I avoided that with this repo since I wanted to keep it as bare bones as possible so people who haven't read my other posts aren't lost. It gets complex pretty quickly. I'll be AFK for the next 12 hours, so hopefully, this solves your problems for now.

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

i have fixed the problem with var app = next({ dev: false, conf: { distDir: "next" } })

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

have you problem with var app = next({ dev: true, conf: { distDir: "next" } })???
I think that we must be increase the timeout of the cloud function...
@jthegedus

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Hi @sarovin, I don't have any errors with either {dev: true, or {dev: false,.

Can you post your pkg.json files?

I found some other issues when using versions of packages < these:

"firebase-admin": "^5.0.1",
"firebase-functions": "^0.6.0",
"next": "beta",

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

i have the same versions...

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Are you producing this error on a clone of this repo or have you modified things? Because I can't reproduce the error. I didn't even know that you could Timeout locally served Firebase Functions! I've asked some q's on the Firebase community Slack channel to see if a Firebaser can advise on this error.

To be clear, you got it to work fine with dev:false, but dev:true throws that same error you originally posted?

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

@i have changed the serve script with this "serve": "firebase serve --port 5000 --only functions,hosting",

If i use only firebase serve i have this error:
Error: NOT_FOUND

my firebase-tools version is 3.9.2...

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

I'm also using that version of firebase-tools. This leads me to believe there is some other issue going on here because you should be able to just use firebase serve.

When using

"serve": "firebase serve --port 5000 --only functions,hosting",

I had this console output
yarn-serve
and the browser showed this error
internal error occurred while connecting to Cloud Function "next"

But with just

"serve: "firebase serve"

I did not have the error functions: Cannot start emulator. Error: Cannot find module '@google-cloud... in the console and the page is hosted correctly.

Maybe this is a Node or Yarn version issue? I've got:
Node: v6.11.1
Yarn: 0.27.5

Failing that, I imagine solving the issue with using firebase serve may fix this issue. You should be able to use it just fine so something is amiss there.

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

That line only shows once I attempt to load the page. I still get an error asking for the Google Cloud Function emulator.

yarn serve

and the page errors of course.
yarn serve 02

The google-cloud/functions-emulator may be causing interference with firebase serve if it's also a global package.

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

i don't understand...you not serve the functions???

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

It seems that when you deploy Firebase Hosting with a Rewrite rule in the firebase.json it knows that there is a function and handles serving the function for you.

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

and if i not deploy but run only serve?
@jthegedus My goal is running nextjs app in development mode in localhost

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Yes.

So when you run firebase deploy, it deploys both the Cloud Function and the Hosting. When you run firebase serve it serves the Hosting, but part of that configuration involves a Cloud Function so it serves the ones it needs behind the scenes.

Try this:

"serve": "firebase serve --port 5000 --only hosting"

it works.

from firebase-functions-next-example.

sarovin avatar sarovin commented on May 19, 2024

...i have tested with "serve": "firebase serve --port 5000 --only hosting" but i have the same issue:

i  hosting: Serving hosting files from: src/public
✔  hosting: Local server: http://localhost:5000

127.0.0.1 - - [08/Aug/2017:15:34:35 +0000] "GET / HTTP/1.1" 404

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Interesting. This may be a config problem in your firebase.json file. Do you mind sharing? If you can't share here you could add me as a read-only user to your repo.

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Bolket/next-firebase-functions#3
So I removed your slasher wrapper for your Cloud Function and it works fine now. Since you're rewriting all routes with **/** in the firebase.json every route without a / will end up at the Next.js app. Next.js already handles the issues around missing /s. You can still use the slasher wrapper for any other Cloud Functions you may create.

When your code was deployed it appeared to work fine, however, it was actually doing a full refresh of each route from the Next.js server instead of client-side caching (a part of Next.js). Removing the slasher from this Cloud Function fixed this issue too.

from firebase-functions-next-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.