Closed SunsetMkt closed 8 months ago
I have tried it , but i didn't work , maybe the Astro 2 doesn't support this feature ?
I'm afraid not. Next.js is by Vercel, so there's an official support.
We could have rewritten the request function using the following method:
import type { VercelRequest, VercelResponse } from '@vercel/node';
export const config = {
runtime: 'edge', // this is a pre-requisite
// execute this function on iad1 or hnd1, based on the connecting client location
regions: ['iad1', 'hnd1'],
};
export default function handler(
request: VercelRequest,
response: VercelResponse,
) {
return response.status(200).json({
text: `I am an Edge Function! (executed on ${process.env.VERCEL_REGION})`,
});
}
But because it is actually wrapped in @google/generative-ai, we cannot modify it.
I'm afraid not. Next.js is by Vercel, so there's an official support.
We could have rewritten the request function using the following method:
import type { VercelRequest, VercelResponse } from '@vercel/node'; export const config = { runtime: 'edge', // this is a pre-requisite // execute this function on iad1 or hnd1, based on the connecting client location regions: ['iad1', 'hnd1'], }; export default function handler( request: VercelRequest, response: VercelResponse, ) { return response.status(200).json({ text: `I am an Edge Function! (executed on ${process.env.VERCEL_REGION})`, }); }
But because it is actually wrapped in @google/generative-ai, we cannot modify it.
but this project is not base on Next.js framework
Yes, so we may try the "Other frameworks" example, but we have to refrain from using @google/generative-ai and must rewrite the functionalities it provides on our own.
The docs require using VercelRequest, VercelResponse from @vercel/node, but @google/generative-ai (actually sends the request) won't follow it.
It is also possible that Google will eventually notice this issue and modify @google/generative-ai. Perhaps we should provide feedback to both Google and Vercel first?
I'm not familiar with modern front-end frameworks, so sorry for any confusion.
this issue has a perfect solution now , see here
Thank you for your efforts.
Just a kindly reminder, proxies are not allowed in Vercel Fair Use Policy, though Vercel seldom intervenes in these matters.
Describe the feature
https://vercel.com/docs/functions/configuring-functions/region
For Edge Functions:
preferredRegions
or specify aregions
key within a config object to set one or more regions for you functions to execute inAdditional context
No response
Participation