'Nextjs dynamic routes in Amplify

I have the following directory structure in my Nextjs app:

pages/post/[id]/index.js

I am trying to configure Amplify to correctly route this URL:

mydomain.com/post/123

I have the following rewrite configured:

{
    "source": "/post/<*>",
    "target": "/post/[id]/index.html",
    "status": "200",
    "condition": null
},

But it isn't working. What is the correct format for the Amplify rewrite when the directory is a dynamic route?

My routes do work when running locally. I can't get it configured in Amplify.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source