Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add user open graph * fix: add proxy for open graph
- Loading branch information
1 parent
fac9a2b
commit 39fc4cb
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { APIRoute } from 'astro'; | ||
|
||
export const prerender = false; | ||
|
||
type Params = { | ||
slug: string; | ||
}; | ||
|
||
export const GET: APIRoute<any, Params> = async (context) => { | ||
const { slug } = context.params; | ||
|
||
if (!slug.startsWith('user-')) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: 'Invalid slug', | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
const username = slug.replace('user-', ''); | ||
if (!username) { | ||
return new Response( | ||
JSON.stringify({ | ||
error: 'Invalid username', | ||
}), | ||
{ | ||
status: 400, | ||
}, | ||
); | ||
} | ||
|
||
const response = await fetch( | ||
`${import.meta.env.PUBLIC_API_URL}/v1-profile-open-graph/${username}`, | ||
); | ||
|
||
const svg = await response.text(); | ||
return new Response(svg, { | ||
headers: { | ||
'Content-Type': 'image/svg+xml', | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters