-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
How to use koa.js + next in firebase functions #1337
Comments
@RezaRahmati server.callback is not the callback by itself, rather a function that generates the callback from your configuration I assumed. You need to do this:
That should do the trick I think. |
@kvindasAB thanks I will try, btw as I remember callback() was returning void not a function, however I try. |
|
@RezaRahmati Have you resolved this issue? |
@gdayton I didn't tried it yet ;) I will try at weekend |
@RezaRahmati Ended up hosting the app on GCP AppEngine and will use Functions for other purposes |
I'm going to close this as it seems to be answered and/or not an issue anymore. Please feel free to re-open if you're still having problems with this. |
@kvindasAB Thanks |
const functions = require('firebase-functions');
const app = new Koa();
...
exports['http'] = functions.https.onRequest(app.callback()); |
Were you able to get the authentication part working? It seems to keep going in a loop and never authenticate.
This does not seem to be creating the /auth and /auth/callback routes properly in the firebase cloud functions environment. Any ideas? |
ever find a solution? i have gotten a little farther into this and will have a fix soon i hope haha |
Wow, if you have the auth loop... Please save yourself the time from feeling like a scrub and forgetting firebase session management is different and just install this: https://community.shopify.com/c/Shopify-Apps/Just-Released-Koa-Firebase-Session-Store/td-p/609260 thank me later |
Was anyone here able to make Shopify OAuth process work with Firebase functions? |
Personally, I ended up just making it from scratch after wasting about 2 weeks trying to get the Shopify sample w/ shopify libs to work in firebase... Took about a half day to get it working. Shopify has great sample code, so it wasn't too bad at all, NOTE: you can use crypto.createHmac and cryto.timingSafeEqual in node for HMAC verification. Also, (I think) firebase only supports session cookies with an underscore, like "_session". So, that's one of the reasons it doesn't work (amongst others)... Fundamentally I think there are so many issues with the Shopify sample app because firebase functions aren't really raw node servers (which is what the Shopify libs are made for). Firebase functions are node apps that (sort of) are already inside an express middleware that runs after a bunch of other middlewares like body parser, form data parser, etc. Hope this helps! |
Actually, I did get it to work long back! There are multiple issues at different levels, after wasting (or using) a lot of time I was able to get it to work. Your missing piece of puzzle is that Next.js will not work with Koa server with Firebase in 'dev' mode! It will work fine in production mode. To test it out, build your Nextjs app with npm run build (which should execute next build) and then try with Firebase functions. In your server.js file, you can export the server like
The firebase function should look like this:
For development you can create a separate local server like below to serve your nextjs app in dev mode
Let me know if face any issue.
|
@amardeepsingh20 Hi there, I'm currently working on |
I want to use
firebase functions
to deploy thereact
application forshopify app
I am new to both
next
andkoa
based on this repo the below code is how to host a simple react application in firebase
Which works correctly, no issue.
Then based on this tutorial from shopify I need to integrate
koa
and other dependencies inserver.js
, which in my case I believe it should be placed inside the firebase function. so I get to this codeMy question is now based on
koa
what code should be infunctions.https.onRequest
?I tried #1, #2, #3, as well as this post
1 -> I get request timeout
2 -> I get request timeout
3 -> I get
Cannot access middleware of undefined
4 -> I get request timeout
The text was updated successfully, but these errors were encountered: