retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.02k stars 201 forks source link

Nav Bar links do not work correctly behind Cloudflare Access #580

Closed aguilaair closed 1 year ago

aguilaair commented 1 year ago

Hello,

We seem to be having trouble with deploying retype behind our authentication layer, with the links in the navbar not being generated correctly. For example, when you navigate to a page that is not the index, the link in the navbar to one of the pages is ./frontend-v1/general/accessusers/ when it should not have the . at the front.

When deploying with Vercel temporary link it seems to work fine, but then production has this issue.

Let me know if you need any info.

geoffreymcgill commented 1 year ago

Can you share your retype.yml file? or is your project available in GitHub?

My first guess is that the url config within your projects retype.yml file is not correct. It might be the correct or valid url for local use, but once deployed to production, the url is different.

geoffreymcgill commented 1 year ago

ah, Cloudflare...

Can you ensure the Cloudflare Rocket Loader feature is turned off?

geoffreymcgill commented 1 year ago

You can determine if Rocket Loader is being used on your website by viewing the HTML source on any of your live production pages and search for the value rocket-loader.

If rocket-loader is found, then the Cloudflare Rocket Loader service is enabled for your website.

You can disable within Cloudflare for you domain by going to:

Speed > Optimization > Content Optimization > Toggle off

Screen Shot 2023-07-04 at 12 34 08 PM

You can also create a Cloudflare Rule to disable Rocket Loader on a per hostname basis.

aguilaair commented 1 year ago

Disabling Rocket Loader seems to have done the trick. Thank you!

aguilaair commented 1 year ago

Is it worth creating an issue to support Rocket Loader, @geoffreymcgill ?

geoffreymcgill commented 1 year ago

Is it worth creating an issue to support Rocket Loader, @geoffreymcgill ?

I think it is very unlikely that Retype will be able to support Rocker Loader, at least for the foreseeable future. It's definitely something that we can investigate at a later time.

I did find a way to configure specific <script> elements so Rocket Loader will ignore:

https://developers.cloudflare.com/fundamentals/speed/rocket-loader/ignore-javascripts/

I'll try adding the data-cfasync="false" attribute and see if that can get everything working with Rocket Loader still enabled for the site. Theoretically, this should work.

geoffreymcgill commented 12 months ago

As of the upcoming v3.1.0 release, Retype now supports Cloudflare Rocket Loader. There are no changes required in your project, other than building with Retype v3.1.0 once it is released.

Even though Retype is now working well, we would still recommend disabling Cloudflare Rocket Loader within your Cloudflare admin panel.