How to get request headers in Vercel
lita-jerry opened this issue · 1 comments
lita-jerry commented
const ctx = useContext()
console.log(ctx)
on vercel print context:
{
app: <ref *1> {
_uid: 1,
_component: {
__name: 'App',
__ssrInlineRender: true,
setup: [Function (anonymous)]
},
_props: null,
_container: null,
_context: {
app: [Circular *1],
config: [Object],
mixins: [],
components: {},
directives: {},
provides: [Object: null prototype],
optionsCache: [WeakMap],
propsCache: [WeakMap],
emitsCache: [WeakMap]
},
_instance: null,
version: '3.3.4',
config: [Getter/Setter],
use: [Function: use],
mixin: [Function: mixin],
component: [Function: component],
directive: [Function: directive],
mount: [Function (anonymous)],
unmount: [Function: unmount],
provide: [Function: provide],
runWithContext: [Function: runWithContext]
},
router: {
currentRoute: RefImpl {
__v_isShallow: true,
dep: undefined,
__v_isRef: true,
_rawValue: [Object],
_value: [Object]
},
listening: true,
addRoute: [Function: addRoute],
removeRoute: [Function: removeRoute],
hasRoute: [Function: hasRoute],
getRoutes: [Function: getRoutes],
resolve: [Function: resolve],
options: { history: [Object], routes: [Array] },
push: [Function: push],
replace: [Function: replace],
go: [Function: go],
back: [Function: back],
forward: [Function: forward],
beforeEach: [Function: add],
beforeResolve: [Function: add],
afterEach: [Function: add],
onError: [Function: add],
isReady: [Function: isReady],
install: [Function: install]
},
initialRoute: {
fullPath: '/',
path: '/',
query: {},
hash: '',
name: 'index',
params: {},
matched: [ [Object], [Object] ],
meta: { layout: 'home' },
redirectedFrom: undefined,
href: '/'
},
url: URL {
href: 'http://serverless-q60b0jumf-jerrysir.vercel.app/',
origin: 'http://serverless-q60b0jumf-jerrysir.vercel.app',
protocol: 'http:',
username: '',
password: '',
host: 'serverless-q60b0jumf-jerrysir.vercel.app',
hostname: 'serverless-q60b0jumf-jerrysir.vercel.app',
port: '',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
isClient: false,
initialState: { pinia: {} },
redirect: [Function: redirect],
writeResponse: [Function: p]
}
get request is undefined, bug i will to use headers 'accept-language', how to do 🌚
JerrySir commented
in App.vue use context on vercel:
import { useContext } from 'vite-ssr'
// ...
const ctx = useContext()
console.log(ctx)
// undefined