Skip to main content

80 posts tagged with "Web Development"

Web Development Technologies and Practices

View All Tags

Fixed: Access to script at 'file:///…' from origin 'null' has been blocked by CORS policy

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

I opened a small web page straight from the disk, and its script didn't run. Chrome's console said Access to script at 'file:///…' from origin 'null' has been blocked by CORS policy. Nothing was wrong with the script: the browser won't make that kind of request for a file on the disk, and a one-line local web server fixes it.

How to Generate a Subresource Integrity (SRI) Hash for a Script in the Terminal

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

A <script> tag that loads code from another site, such as a CDN, runs whatever that site sends. An integrity attribute with the file's hash makes the browser check the file first, and refuse to run it if even one character changed. You make the hash with one command in the terminal.

How to Set a Cache-Control Header for One Page in Next.js

· 14 min read
Jagdish Kumawat
Founder @ Dewiride

Next.js chooses each page's Cache-Control header from the way the page renders, and a static page gets s-maxage=31536000: a year in any shared cache. When one page needs a different header, such as no-store for a page whose address carries a one-time code, a headers() rule in next.config.ts sets it for that page alone. This guide adds one and checks it on a production build, the only place the default shows.