-
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #126 from aiji42/fix/preflight
fix: handle fallback on preflight
- Loading branch information
Showing
27 changed files
with
1,870 additions
and
1,722 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
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
File renamed without changes.
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,14 @@ | ||
import { NextApiHandler } from 'next' | ||
import { destroyCookie } from 'nookies' | ||
|
||
const handler: NextApiHandler = async (req, res) => { | ||
if (req.method !== 'POST') return res.status(404).send('Not Found') | ||
|
||
destroyCookie({ res }, 'session', { | ||
path: '/' | ||
}) | ||
|
||
res.send(JSON.stringify({ status: 'success' })) | ||
} | ||
|
||
export default handler |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { makeIPInspector } from 'next-fortress' | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import { NextMiddleware, NextResponse } from 'next/server' | ||
|
||
export const middleware = (req: NextRequest) => { | ||
export const middleware: NextMiddleware = (req, event) => { | ||
if (!req.nextUrl.pathname.includes('admin')) return | ||
const ips = req.cookies['__allowed_ips'] | ||
if (!ips) return NextResponse.redirect('/ip') | ||
if (!ips) { | ||
if (req.preflight) return new NextResponse(null) | ||
return NextResponse.redirect('/ip') | ||
} | ||
|
||
return makeIPInspector(ips.split(','), { | ||
type: 'redirect', | ||
destination: '/ip' | ||
})(req) | ||
})(req, event) | ||
} |
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
Oops, something went wrong.
cd0dbda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: