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;
|
process.env.DATABASE_URL = config.core.database_url;
|
||||||
|
|
||||||
await stat('./.next');
|
// await stat('./.next');
|
||||||
await mkdir(config.uploader.directory, { recursive: true });
|
await mkdir(config.uploader.directory, { recursive: true });
|
||||||
|
|
||||||
const app = next({
|
const app = next({
|
||||||
|
|
|
@ -86,6 +86,11 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
|
|
||||||
if (!image) return { notFound: true };
|
if (!image) return { notFound: true };
|
||||||
|
|
||||||
|
if (!image.embed) return { redirect: {
|
||||||
|
permanent: true,
|
||||||
|
destination: '/r/' + image.file,
|
||||||
|
} };
|
||||||
|
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
select: {
|
select: {
|
||||||
embedTitle: true,
|
embedTitle: true,
|
||||||
|
@ -100,7 +105,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
if (!image.mimetype.startsWith('image')) return {
|
if (!image.mimetype.startsWith('image')) return {
|
||||||
redirect: {
|
redirect: {
|
||||||
permanent: true,
|
permanent: true,
|
||||||
destination: `raw/${image.file}`,
|
destination: '/r/' + image.file,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue