remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.09k stars 10.31k forks source link

[Bug]: `ReferenceError: URL is not defined` in encodeLocation #11010

Closed ANKITCHAUDHARY-15 closed 1 year ago

ANKITCHAUDHARY-15 commented 1 year ago

What version of React Router are you using?

6.18.0

Steps to Reproduce

Getting this error in server side rendering Routing code : `

} /> } />

`

Error

{Microsoft.ClearScript.ScriptEngineException: ReferenceError: URL is not defined ---> Microsoft.ClearScript.ScriptEngineException: ReferenceError: URL is not defined at Microsoft.ClearScript.V8.SplitProxy.V8SplitProxyNative.Invoke[T](Func2 func) at Microsoft.ClearScript.V8.V8ScriptEngine.ExecuteInternal(UniqueDocumentInfo documentInfo, String code, Boolean evaluate) at Microsoft.ClearScript.V8.V8ScriptEngine.<>c__DisplayClass130_0.<Execute>b__0() at Microsoft.ClearScript.ScriptEngine.ScriptInvokeInternal[T](Func1 func) at Microsoft.ClearScript.V8.V8ScriptEngine.<>c__DisplayClass137_01.<ScriptInvoke>b__0() at Microsoft.ClearScript.V8.SplitProxy.V8SplitProxyManaged.InvokeHostAction(IntPtr pAction) --- Script error details follow --- ReferenceError: URL is not defined at encodeLocation (<anonymous>:273:69) -> throw err; at eval (<anonymous>:443:42) at useRoutesImpl (<anonymous>:439:59) at useRoutes (<anonymous>:377:10) at Routes (<anonymous>:1178:10) at processChild (<anonymous>:3089:14) at resolve (<anonymous>:3012:5) at render (<anonymous>:3435:22) at read (<anonymous>:3394:29) at renderToString (<anonymous>:3953:27) at Script [3]:1:16 --- End of inner exception stack trace --- at Microsoft.ClearScript.V8.SplitProxy.V8SplitProxyNative.Invoke(Action1 action) at Microsoft.ClearScript.V8.SplitProxy.V8ContextProxyImpl.InvokeWithLock(Action action) at Microsoft.ClearScript.V8.V8ScriptEngine.ScriptInvoke[T](Func`1 func) at JavaScriptEngineSwitcher.V8.V8JsEngine.InnerEvaluate(String expression, String documentName) --- Script error details follow --- ReferenceError: URL is not defined at encodeLocation (:273:69) -> throw err; at eval (:443:42) at useRoutesImpl (:439:59) at useRoutes (:377:10) at Routes (:1178:10) at processChild (:3089:14) at resolve (:3012:5) at render (:3435:22) at read (:3394:29) at renderToString (:3953:27) at Script [3]:1:16}

timdorr commented 1 year ago

Duplicate of #10887