Posts

Showing posts with the label standalone

Setup NextJS project with Bun

Image
Introduction Bun is a modern JavaScript runtime built with the goal of optimizing performance and improving the development experience. In addition to being compatible with the NodeJS ecosystem, Bun also integrates a package manager, bundler and test runner in the same tool. Some outstanding advantages of Bun: Dependency installation speed is significantly faster than npm, yarn and even pnpm. High startup and application execution performance thanks to being written in Zig. Integrates multiple tools in one runtime, helping reduce the number of dependencies required. Supports projects using modern frameworks like NextJS and NestJS well. Helps shorten build times and optimize the CI/CD process. Detail Note that although using Bun can provide comprehensive and effective support for NPM packages, there are still many risks regarding compatibility with older package versions. If the project you are developing is relatively large and has been operating for a long time, consider carefully bef...

Handling CORS and Rate Limit with Reverse Proxy in NextJS

Image
Introduction In the previous article, I guided you on using rewrites and proxy in NextJS. Now, we will go into a specific case to set up rate limit directly from the NextJS server to reduce the actual number of requests sent to the core service. Also in this article, I will guide you on how to configure NextJS as a reversed proxy to avoid CORS errors on the browser effectively. CORS (Cross-Origin Resource Sharing) is an HTTP-based security mechanism enforced by browsers to prevent websites from sending requests to a domain different from the current website domain (except when the target domain explicitly permits it via response HTTP headers). When the browser makes an API request to a cross origin target and the server has not configured allowance for that domain, the following error occurs: Solutions Browser-side handling (exercise caution, not recommended): you can use certain extensions or disable this feature on the browser to bypass it, but the risk is extremely high because thi...