-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from DNDACADEMY/develop
- Loading branch information
Showing
14 changed files
with
1,030 additions
and
943 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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,25 @@ | ||
import { revalidatePath } from 'next/cache'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export async function GET(request: NextRequest) { | ||
const secret = request.nextUrl.searchParams.get('secret'); | ||
const paths = request.nextUrl.searchParams.get('paths'); | ||
|
||
if (secret !== process.env.REVALIDATION_TOKEN) { | ||
return NextResponse.json({ revalidated: false, message: 'Invalid token' }, { status: 401 }); | ||
} | ||
|
||
if (!paths) { | ||
return NextResponse.json({ revalidated: false, message: 'Path is required' }, { status: 400 }); | ||
} | ||
|
||
try { | ||
paths.split(',').forEach((path) => { | ||
revalidatePath(path); | ||
}); | ||
return NextResponse.json({ revalidated: true, now: Date.now() }); | ||
} catch (err) { | ||
return NextResponse.json({ revalidated: false, message: 'Error revalidating' }, { status: 500 }); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export const ONE_HOUR = 3600; | ||
|
||
export const ONE_DAY = 86400; |
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,20 @@ | ||
import type { NextRequest } from 'next/server'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export function middleware(request: NextRequest) { | ||
const response = NextResponse.next(); | ||
|
||
if (request.nextUrl.pathname.startsWith('/api/revalidate')) { | ||
response.headers.set('Access-Control-Allow-Origin', process.env.ADMIN_ORIGIN); | ||
response.headers.set('Access-Control-Allow-Methods', 'GET,OPTIONS'); | ||
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization'); | ||
} | ||
|
||
return response; | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
'/api/revalidate/:path*', | ||
], | ||
}; |
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 |
---|---|---|
|
@@ -50,5 +50,5 @@ | |
"email": "[email protected]", | ||
"url": "https://github.com/DNDACADEMY/dnd-academy-v2/issues" | ||
}, | ||
"packageManager": "yarn@4.3.1" | ||
"packageManager": "yarn@4.4.0" | ||
} |