[SOLVED] AWS Amplify: cannot access specific page via /page-name, only by starting at / and shallow routing

0

UPDATE

This is solved. I found the solution via this StackOverflow link, which details the following approach:

From the Amplify console, you can access the Rewrites and redirects menu item in left sidebar. From there you can update the redirect rule to these settings:

Source address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address: /index.html
Type: 200

Original Question

Source address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address: /index.html
Type: 200

My team and I just started hosting our UI on AWS Amplify. When accessing the page, we are able to access main.xxxxxxxxx.amplifyapp.com/ directly to get to the home page. We can then navigate to other pages from there, which causes the browser to shallow route to that page. For example, starting at / and clicking a link that calls...

const navigate = useNavigate();
navigate({ pathname: "/search" })

...works fine, since that's shallow routing; but attempting to go to main.xxxxxxxxx.amplifyapp.com/search using the browser's omnibar returns a 404.

We tried starting at / and clicking our way to other pages, which works fine, as this uses shallow routing. If we start at /page-name directly, Amplify returns a 404 Not Found on the page.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠