提交 580c13a0 编写于 作者: G Guy Bedford 提交者: Joe Haddad

cookie

上级 0adb310c
import { parse } from 'next/dist/compiled/content-type'
import { CookieSerializeOptions } from 'cookie'
import { CookieSerializeOptions } from 'next/dist/compiled/cookie'
import { IncomingMessage, ServerResponse } from 'http'
import { PageConfig } from 'next/types'
import getRawBody from 'raw-body'
......@@ -181,7 +181,7 @@ export function getCookieParser(req: IncomingMessage) {
return {}
}
const { parse } = require('cookie')
const { parse } = require('next/dist/compiled/cookie')
return parse(Array.isArray(header) ? header.join(';') : header)
}
}
......@@ -384,7 +384,9 @@ function setPreviewData<T>(
)
}
const { serialize } = require('cookie') as typeof import('cookie')
const {
serialize,
} = require('next/dist/compiled/cookie') as typeof import('cookie')
const previous = res.getHeader('Set-Cookie')
res.setHeader(`Set-Cookie`, [
...(typeof previous === 'string'
......@@ -417,7 +419,9 @@ function clearPreviewData<T>(res: NextApiResponse<T>): NextApiResponse<T> {
return res
}
const { serialize } = require('cookie') as typeof import('cookie')
const {
serialize,
} = require('next/dist/compiled/cookie') as typeof import('cookie')
const previous = res.getHeader('Set-Cookie')
res.setHeader(`Set-Cookie`, [
...(typeof previous === 'string'
......
......@@ -63,7 +63,6 @@
"autodll-webpack-plugin": "0.4.2",
"cache-loader": "4.1.0",
"conf": "5.0.0",
"cookie": "0.4.0",
"css-loader": "3.3.0",
"cssnano-simple": "1.0.0",
"devalue": "2.0.1",
......@@ -191,6 +190,7 @@
"ci-info": "2.0.0",
"compression": "1.7.4",
"content-type": "1.0.4",
"cookie": "0.4.0",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"nanoid": "2.0.3",
......
......@@ -284,6 +284,13 @@ export async function ncc_content_type(task, opts) {
.target('dist/compiled/content-type')
}
// eslint-disable-next-line camelcase
export async function ncc_cookie(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('cookie')))
.ncc({ packageName: 'cookie' })
.target('dist/compiled/cookie')
}
// eslint-disable-next-line camelcase
export async function ncc_dotenv(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('dotenv')))
......@@ -357,6 +364,7 @@ export async function precompile(task) {
'ncc_ci_info',
'ncc_compression',
'ncc_content_type',
'ncc_cookie',
'ncc_dotenv',
'ncc_dotenv_expand',
'ncc_nanoid',
......
......@@ -71,6 +71,10 @@ declare module 'next/dist/compiled/content-type' {
import m from 'content-type'
export = m
}
declare module 'next/dist/compiled/cookie' {
import m from 'cookie'
export = m
}
declare module 'next/dist/compiled/dotenv' {
import m from 'dotenv'
export = m
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册