fix: query info in fc (#6572)

* fix: compatible with query parsing errors caused by ctx.req.url  error in the fc environment

* chore: add changelog
This commit is contained in:
水澜 2023-10-11 09:55:26 +08:00 committed by GitHub
parent aa29b37b59
commit df854102c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---
fix: compatible with query parsing errors caused by ctx.req.url error in the fc environment

View File

@ -10,7 +10,9 @@ export interface Location {
*/
export default function getRequestContext(location: Location, serverContext: ServerContext = {}): RequestContext {
const { pathname, search } = location;
const query = parseSearch(search);
// Use query form server context first to avoid unnecessary parsing.
// @ts-ignore
const query = serverContext?.req?.query || parseSearch(search);
const requestContext: RequestContext = {
...(serverContext || {}),