chipzoller / hugo-clarity

A theme for Hugo based on VMware Clarity
Other
571 stars 263 forks source link

[Bug] CORS error when using www. subdomain, .css and .js files not loading #375

Closed ChadThackray closed 1 year ago

ChadThackray commented 2 years ago

I confirm:

Hugo version

hugo v0.102.0-DEV-7efb35680f4deb82773554be9eb3188d47e6ee0d+extended linux/amd64 BuildDate=2022-08-26T16:50:51Z

Where is this bug showing up?

In the browser: Hugo builds the site, but something doesn't look right.

Operating system

Linux Mint 20.3

Browser (if applicable)

Brave v1.43.89

Current behavior

CORS error when accessing the www.domain.com subdomain.

The error also seems to prevalent on the demo site. If you access www.neonmirrors.net the .css and .js static content won't load. Images seem to be fine.

Expected behavior

The static content should load without any additional configuration by the user in nginx, apache, etc.. I'm using the m10c theme for another website of mine and it loads the static content for both domains with no issues.

Steps to reproduce

See the www. subdomain of the demo site

Relevant log output

No response

Related code

No response

Preferred solution

No response

Other information

No response

onweru commented 2 years ago

@ChadThackray, please ensure that in your config.toml file, the baseURL entry has the www., else you will continue to observe the issue(s) you have described 👆🏼

onweru commented 2 years ago

@ChadThackray, @chipzoller, I think in your server configurations, you ought to configure 301 redirects from the apex domain (no-www) to www, or vice versa. At least it's the standard practice

ChadThackray commented 2 years ago

Thanks @onweru !

@ChadThackray, please ensure that in your config.toml file, the baseURL entry has the www., else you will continue to observe the issue(s) you have described 👆🏼

I tried this before and got the converse issue, then only www.domain.com worked and not domain.com.

@ChadThackray, @chipzoller, I think in your server configurations, you ought to configure 301 redirects from the apex domain (no-www) to www, or vice versa. At least it's the standard practice

Oh ok, didn't know this was the standard procedure. Still strange that it worked for some other hugo themes but not for this one.

Hopefully this issue will help anyone having the same problem in the future.

rootwork commented 1 year ago

Going to mark this as fixed given the last comment.