Runtime error on Next.js with mirage
See original GitHub issueHello,
I’m trying to setup miragejs with my Next.js Project.
But when I setup mirage server with <Link>
in Next.js it shows following error.
import { Server } from "miragejs"
new Server({
routes() {
this.get("/api/movies", () => ({
movies: [
{ id: 1, name: "Inception", year: 2010 },
{ id: 2, name: "Interstellar", year: 2014 },
{ id: 3, name: "Dunkirk", year: 2017 },
],
}))
},
})
export default function Home() {
return (
<div>
<Link href="/posts">
<a>Posts</a>
</Link>
<p>index page</p>
</div>
)
}
Does anyone knows about this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Develop a Next.js page with Mirage
Mock out client-side API requests directly within a page of your Next.js app so you can continue local development without any backend services....
Read more >Next.js Unhandled Runtime Error "Failed to load script
I'm seeing the same thing. I tried adding the URL in the 'as' attribute of the Link component, but that did not help....
Read more >Unhandled Runtime Error There was an Error While Hydrating ...
UnhandledRuntimeError #react-hydration-errordocshttps:// nextjs.org/docs/messages/react-hydration-errorlike and subscribesupport this channel ...
Read more >20 Reasons Why You Need To Stop Being Highly Obsessed ...
JavaScript's strict mode isn't always the profounded choice ... When I enter strict mode and run the code, a runtime error will occur:....
Read more >Work journal - Sam Selikoff
Published "Auth-based route guards in Next.js and debugging in production", ... React will delegate to them in the event of a render-time error....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Gotcha - thanks for digging into this @arsnl!
The passthrough API is indeed weird in that it inherits any previously set namespace, but you can actually rest it back to the empty string before calling passthrough() if you want it to work on the root of the current domain, like this:
I think the “real” solution here is to improve the passthrough/namespace API so it’s clear how the prefix is applied.
Depending of how your routes are defined in your mock server, you gonna have to set the passthrough differently.
If don’t use the namespace, you can use the global
passthrough()
at the end of all your routes or a specificpassthrough("/_next/static/development/_devPagesManifest.json")
.If you are using the namespace, you gonna have to use the solution proposed by @ynotdraw since I think the call for
/_next/static/development/_devPagesManifest.json
gonna be resolved toapi/_next/static/development/_devPagesManifest.json
(if the namespace isapi
). So, the call forGET /_next/static/development/_devPagesManifest.json
will not be filtered by the passthrough.