Setting up rewrite//redirect rules on AWS amplify with nextjs [tag]

Viewed 283

I am building a SSG web application using nextjs. On local machine, everything works as intended but on deployed machine(aws amplify), I had to add several conditions for rewrite/redirect rules. (It's, I guess, because of the tags).

[Rewrites and redirects]

/<*>                                      /index.html                 404 (Rewrite)
/e/<*>                                    /e/[eId]                    200 (Rewrite) -
/n/<*>                                    /n/[nId]                    200 (Rewrite) -
/s/<\d{1,2}>                              /s/[sId]                    200 (Rewrite) -
/s/<\d{1,2}>/s                            /s/[sId]/s                  200 (Rewrite) -
/s/<\d{1,2}>/i/<\d{1,2}>                  /s/[sId]/i/[iId]            200 (Rewrite) -
/s/<\d{1,2}>/s/<\d{1.2}>                  /s/[sId]/s/[sId2]       200 (Rewrite) -
/s/<\d{1,2}>/s/<\d{1.2}>/i/<\d{1,2}>      /s/[sId]/s/[sId2]/i/[iId]   200 (Rewrite) -

QUESTION!! With this condition, I want to add another path like /<someId> to /[someId]

For instance, I want "some.domain/helloworld".

Currently it redirects to "some.domain/helloworld/" (additional / at the end)

I read the AWS amplify Documentation and it says I need to add

{
    "source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",
    "target": "/index.html",
    "status": "200",
    "condition": null
}

that breaks the whole rewrite conditions...

FYI, I am not 100% sure the rewrite/redirect rules that I wrote is right so any comment would be really appreciated.

0 Answers
Related