refactor(api): redirect non-embedded images to /r

This commit is contained in:
diced 2021-09-03 16:40:50 -07:00
parent 7b44f17a64
commit 002bd2e6f7
No known key found for this signature in database
GPG key ID: 85AB64C74535D76E
2 changed files with 7 additions and 2 deletions

View file

@ -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({

View file

@ -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,
}
};