CORS issue when using RelPermalink on integrity check

I stumbled upon a weird bug today, I’d love your input on that.

I’m using Hugo’s built-in integrity check on resources, for my JavaScript. I had it set to it made use of .Permalink and everything was working fine.

I did a quick commit in which I changed all my .Permalink to .RelPermalink (easier to test deploys on Netlify) and suddenly I was hit with a CORS error. Going back to using .Permalink on these assets fixed the issue.

You can check the problematic deploy here: https://5eaaed0e44a863000654e9c3--primative.netlify.app/ (check out the console).

Can anyone tell me why this behavior occurs? Is it normal? And is there a way (for consistency sake on my code) to use only .RelPermalink and still benefit from assets integrity check?

Thanks everyone. :smile:

May be origin of this pb is not this Rel change ?

https://validator.w3.org/nu/?doc=https%3A%2F%2F5eaaed0e44a863000654e9c3--primative.netlify.app%2F

These problems are there even on the fixed version.

I just realized that when using the relative links, Hugo links them to Cloudflare, while when using the abslute URLs, it links them to my domain. I guess that Netlify injects the cloudflare URL when using relative links and that’s where the problem is coming from.

Which I guess means that you have set up some “Netlify assets optimization”. I would report this as a bug to Netlify, They cannot take a resources with a integrity hash applied to it and change the content and expect it to work.

1 Like

Yes I do. I’ll try to ping Netlify about this issue. Thanks bep!