Is it possible to deploy t3 app on firebase?

I have specific requirement of running the serverless function for more than 5 minutes. and vercel does not support it. where as firebase provides max timeout of 60 min. which is perfectly suitable for me. Greatly appreciate any other suggestion?
5 Replies
matevzzzz
matevzzzz2y ago
can i ask what the function does? could there be a better way to process the logic? Does it need to be 5 minutes or is that just an estimate of how long it runs?
.snkt
.snktOP2y ago
I am using open api apis. about 30 calls. each takes avg. 10 sec. 30*10=300 sec. and each next call depends on previous call's response.
Alejo
Alejo2y ago
Yes, you can, I've done it before with this code under a file in the path functions/index.ts
import { https } from "firebase-functions";
import next from "next";

const server = next({ dev: false, conf: { distDir: ".next" } });

const handler = server.getRequestHandler();

export const nextSSR = https.onRequest(async (req, res) => {
await server.prepare();
await handler(req, res);
});
import { https } from "firebase-functions";
import next from "next";

const server = next({ dev: false, conf: { distDir: ".next" } });

const handler = server.getRequestHandler();

export const nextSSR = https.onRequest(async (req, res) => {
await server.prepare();
await handler(req, res);
});
And this code in the firebase.json file
{
"functions": {
"source": ".",
"predeploy": "npm run fb:build"
},
"hosting": {
"public": "out",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"cleanUrls": true,
"rewrites": [
{
"source": "**",
"function": "nextSSR"
}
]
}
}
{
"functions": {
"source": ".",
"predeploy": "npm run fb:build"
},
"hosting": {
"public": "out",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"cleanUrls": true,
"rewrites": [
{
"source": "**",
"function": "nextSSR"
}
]
}
}
Though I will say that I am a bit skeptical about an endpoint taking 5 minutes for non-dev/testing purposes, can't you break those 30 calls down, say maybe have the client make 30 independent calls? 5 minutes is a lot and, with just slightly unstable internet, the chances of that connection dropping mid-request are VERY high. If you break it into shorter client calls not only you can show the client a better idea of progress in the process but also you don't have to start all over if one of the requests fails
.snkt
.snktOP2y ago
@Alejo thanks great suggestion. I will look into it. btw have you notices any problems when working with the firebase deployed next.js? I am a little skeptical using it in prod, as Firebase site says it's in early public preview.
Alejo
Alejo2y ago
It hasn't given me any issues I can think of, though it is a very low traffic tool, practically an internal tool for a friend
Want results from more Discord servers?
Add your server