question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All routes redirecting to root index.html on a hard refresh

See original GitHub issue

Was able to get my site deployed using this plugin and everything was looking good until I realized that when you’re not using the client side routing, that all pages redirect to the root index.html page.

I am using Cloudfront to serve up assets and I’m not sure if its a configuration option with this plugin or if its a setting I have in AWS for my root document.

I’ve also invalidated my Cloudfront cache a couple of times with the instructions outlined in the docs

Should I have to set my root and error documents in Cloudfront and in the S3 static website hosting options? If so, should they both be set to index.html or /index.html? I have three levels of subdirectories, each with an index.

Here is the site live with the issue - https://www.drewtempleton.com – You can navigate to https://www.drewtempleton.com/photos/travel/montana within the website and it works but if you curl that endpoint with no cache or incognito, it redirects back to the root index.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
JoshuaWalshcommented, Feb 9, 2019

Hi @drewbietron,

I think I know what the issue is now. I believe if you look in your CloudFront Origin configuration, you’ll find that the origin URL is www.drewtempleton.com.s3.amazonaws.com. You instead need it to say www.drewtempleton.com.s3-website-us-east-1.amazonaws.com. This is mentioned in the documentation, but maybe we can improve it to be more obvious.

Please give this a try (and remove the 403 error page in CloudFront again) and let me know if it’s fixed. After you make the change you’ll need to wait for the Distribution to update (might take 30 minutes) and you might also need to do an invalidation.

Thanks, Josh

2reactions
jarizcommented, Mar 10, 2019

Gonna close this now, let me know if you’re still running into any problems after implementing @JoshuaWalsh’s suggestions, @drewbietron.

Read more comments on GitHub >

github_iconTop Results From Across the Web

S3 Static Website Hosting Route All Paths to Index.html
What I need is the ability to take all url requests and serve up the root index.html in my S3 bucket, rather than...
Read more >
Apache 2.2 rewrite - Force all requests to index.html
Using an .htaccess on the root folder this should do the job: RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteRule .
Read more >
Fixing the 'cannot GET /URL' error on refresh with React ...
The first, set up both client and server side routing. The second, redirect all server requests to /index.html which will download all the ......
Read more >
(Optional) Configuring a webpage redirect
Configure your bucket as a website by setting up redirect locations where you can redirect requests for an object to another object.
Read more >
next.config.js: Redirects
Redirects are not applied to client-side routing ( Link , router.push ), unless Middleware is present and matches the path. When a redirect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found