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

Directory output of package that is deployed #1

Closed
jthegedus opened this issue Jun 24, 2017 · 6 comments
Closed

Directory output of package that is deployed #1

jthegedus opened this issue Jun 24, 2017 · 6 comments
Labels

Comments

@jthegedus
Copy link

jthegedus commented Jun 24, 2017

Hi @geovanisouza92 , thanks for this repo. I've come across vercel/next.js#2123 and wanted to ask a few questions but didn't want to further populate that thread. If this isn't an appropriate channel to discuss things let me know.

I've been trying to achieve a similar thing to what you have done here, but with Firebase Cloud Functions. I've run into a couple of issues with the packaging of my app with the ./next folder as well as the build-stats.json file (probably related to vercel/next.js#1720 ).

Anyway, I was wondering what the uploaded package directory structure looked like with your solution and how you solved these issues, expanding on your comment here if possible.

Update
For future finders these are related:
firebase/firebase-tools#291
firebase/firebase-tools#376

@geovanisouza92
Copy link
Owner

geovanisouza92 commented Jun 26, 2017

Hi @jthegedus, thank you for the issue.Yeah, I think this is a nice place for discussion about this.

Sorry for the delay, I was trying to create a minimal reproducible example, mostly because I was curious about it too. 😝

So, till now, I was able to make it barely works locally using a proxy because Next.js assumes too much about routing (I'll probably make an issue/PR about that), and the deploy, just changing the distDir. Right now, it still fail, due to a routing problem (here I'm guessing that FCF req object didn't have all information of the original request).

Due the nature Router seems to be working, I guess that the default domain that Fb provides will not work normally, because it's path-based, while Next.js seems to assume a root/sub domain everywhere.


EDIT: vercel/next.js#257 has some clues

@jthegedus
Copy link
Author

@geovanisouza92 I see. I was going to do that too 😄 Another issue I was having with my larger repo was that the next app and functions are in different nested dirs and I haven't troubleshoot to determine if that was a contributing factor or a different problem all together. vercel/next.js#1720 seems more related to that.

'm guessing that FCF req object didn't have all information of the original request

When the req gets to the function body it has already been parsed by bodyParser as per https://firebase.google.com/docs/functions/http-events#read_values_from_the_request

Another possibly related thing I have also got working through a little playing was serving a Cloud Function from the root URL via Firebase Hosting.

I will update here linking to my example repo for each problem I have encountered and discovered some random hack for, and hopefully combined with what you have done here may solve each issue of the process.

@geovanisouza92
Copy link
Owner

geovanisouza92 commented Jun 27, 2017

I'm guessing that FCF req object didn't have all information of the original request

I'm actually confirmed this console.log'ing req.url:

Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: null,
  port: null,
  hostname: null,
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: '' }

The point is: how can we "route" requests through Next, when there are no urls?


EDIT: I could make it work on FCF. Just need to make dev/prod more streamlined. (Code at https://github.com/geovanisouza92/serverless-firebase)

@jthegedus
Copy link
Author

I've made some progress on top of what you have developed. I've got deployment and redirecting using dynamic serving through FB Hosting working. The only issue I have now is the Route resolving for pages other than the initial load. I'll have a PR done within the next 10 hrs (AEST/UTC+10 timezone and it's early 😛 ) with these working updates.

Thus far the only other issue I can think of that we may not be able to resolve until an update (to Firebase or Next.js) is having the app in a subdirectory - like this the directory structure defined here vercel/next.js#1720

@jthegedus
Copy link
Author

jthegedus commented Jun 28, 2017

Here's the PR geovanisouza92/serverless-firebase#1

  • This fixes routing issues via using Dynamic Content Hosting on Firebase Hosting.
  • Firebase Serve is all that is needed for local development as Hosting redirects work with Cloud Functions as expected when running locally.
  • Firebase Hosting fixes the issues with trailing /s.
  • The URL to the app is now the Firebase Hosting URL instead of the function.
  • For Firebase Hosting to deploy, there needs to be a file in the deploy dir (./public). An empty file fulfils the condition and then the deployment progresses and ultimately the redirect works.

Issues:

  • The first page load in a browser has some errors logged to the console - I have not had the time to troubleshoot this yet, but the app works as expected.
  • The logging from Firebase Serve references some 404 error but the code runs correctly - I have not had the time to troubleshoot this yet, but the app works as expected.

Sorry about the mess in the PR created by Prettier changing the ' to " - The only non-default Prettier setting I use is --no-semi in VSCode

@jthegedus
Copy link
Author

I've updated the serverless-firebase repo PR to contain all my fixes to these issues (as far as I can tell). Thanks heaps for your help getting started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants