refactor(api): redirect non-embedded images to /r
This commit is contained in:
parent
7b44f17a64
commit
002bd2e6f7
2 changed files with 7 additions and 2 deletions
|
@ -45,7 +45,7 @@ function shouldUseYarn() {
|
|||
}
|
||||
process.env.DATABASE_URL = config.core.database_url;
|
||||
|
||||
await stat('./.next');
|
||||
// await stat('./.next');
|
||||
await mkdir(config.uploader.directory, { recursive: true });
|
||||
|
||||
const app = next({
|
||||
|
|
|
@ -86,6 +86,11 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||
|
||||
if (!image) return { notFound: true };
|
||||
|
||||
if (!image.embed) return { redirect: {
|
||||
permanent: true,
|
||||
destination: '/r/' + image.file,
|
||||
} };
|
||||
|
||||
const user = await prisma.user.findFirst({
|
||||
select: {
|
||||
embedTitle: true,
|
||||
|
@ -100,7 +105,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||
if (!image.mimetype.startsWith('image')) return {
|
||||
redirect: {
|
||||
permanent: true,
|
||||
destination: `raw/${image.file}`,
|
||||
destination: '/r/' + image.file,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue