Skip to content

Commit

Permalink
[fix] Host Domain of OAuth 2 signer
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Aug 22, 2024
1 parent d83924b commit 427895b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-ssr-middleware",
"version": "0.8.5",
"version": "0.8.6",
"license": "LGPL-3.0-or-later",
"author": "[email protected]",
"description": "Koa-like middlewares for Next.js Server Side Rendering",
Expand Down Expand Up @@ -36,7 +36,7 @@
"husky": "^9.1.5",
"koajax": "^2.0.0",
"lint-staged": "^15.2.9",
"next": "^14.2.5",
"next": "^14.2.6",
"open-cli": "^8.0.0",
"prettier": "^3.3.3",
"typedoc": "^0.26.6",
Expand Down
8 changes: 5 additions & 3 deletions source/middleware/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface OAuth2Props<T extends DataObject> {
user: T;
}

const { VERCEL_URL } = process.env;
const Host = VERCEL_URL ? `https://${VERCEL_URL}` : 'http://127.0.0.1:3000';
const DOMAIN = process.env.VERCEL_PROJECT_PRODUCTION_URL;
const Host = DOMAIN ? `https://${DOMAIN}` : 'http://127.0.0.1:3000';

export function oauth2Signer<I extends DataObject, O extends DataObject = {}>({
signInURL,
Expand All @@ -31,7 +31,9 @@ export function oauth2Signer<I extends DataObject, O extends DataObject = {}>({
}: OAuth2Option): Middleware<I, O> {
return async ({ req: { url, headers, cookies }, query, res }, next) => {
const token = cookies[tokenKey];
const pageURL = new URL(url || '/', headers['origin'] || Host) + '';
const pageURL =
new URL(url || '/', headers['origin'] || headers['host'] || Host) +
'';

if (query.code) {
const token = await accessToken(query as OAuth2Ticket);
Expand Down

0 comments on commit 427895b

Please sign in to comment.