<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: alfanfauzy</title>
    <description>The latest articles on Forem by alfanfauzy (@alfanfauzy).</description>
    <link>https://forem.com/alfanfauzy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F468837%2F2bd29592-b102-4f64-8ea2-9f743bf85690.jpg</url>
      <title>Forem: alfanfauzy</title>
      <link>https://forem.com/alfanfauzy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/alfanfauzy"/>
    <language>en</language>
    <item>
      <title>Fixing a Weird Next.js Chunk Loading Issue Caused by Load Balancer URL Normalization</title>
      <dc:creator>alfanfauzy</dc:creator>
      <pubDate>Mon, 29 Sep 2025 07:50:30 +0000</pubDate>
      <link>https://forem.com/alfanfauzy/fixing-a-weird-nextjs-chunk-loading-issue-caused-by-load-balancer-url-normalization-267g</link>
      <guid>https://forem.com/alfanfauzy/fixing-a-weird-nextjs-chunk-loading-issue-caused-by-load-balancer-url-normalization-267g</guid>
      <description>&lt;h4&gt;
  
  
  &lt;strong&gt;When Everything Works in Office, but Breaks in Client’s Server&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Recently I faced an interesting bug when deploying a Next.js project.&lt;br&gt;
On our office server, everything worked perfectly. But when the same Docker image was deployed in our client’s environment, the app broke — &lt;em&gt;static chunks could not be loaded&lt;/em&gt;.&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;The Symptom&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;My app uses a dynamic route like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   app/feature/[work_id]/listing/page.tsx

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So Next.js generates static chunks with an encoded path like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   /_next/static/chunks/app/feature/%5Bwork_id%5D/listing/page-xxxxx.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But in the client’s server, I noticed requests were being made to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   /_next/static/chunks/app/feature/%5bwork_id%5d/listing/page-xxxxx.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spot the difference? &lt;code&gt;%5B&lt;/code&gt; vs &lt;code&gt;%5b&lt;/code&gt;.&lt;br&gt;
Both are technically valid encodings of &lt;code&gt;[&lt;/code&gt; but they are not the same string.&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;Why Did This Happen?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It turned out to be related to their load balancer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL encoding is case-insensitive (&lt;code&gt;%5B&lt;/code&gt; = &lt;code&gt;%5b&lt;/code&gt; = &lt;code&gt;[&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;But depending on the load balancer/proxy settings, hex characters can be normalized into lowercase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my office environment, the load balancer kept it uppercase.&lt;br&gt;
In the client environment, it forced lowercase.&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;The Impact&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Next.js expected chunks at &lt;code&gt;%5Bwork_id%5D&lt;/code&gt;, but the request came in as &lt;code&gt;%5bwork_id%5d&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Result: the chunk was not found, and the page broke.&lt;/strong&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;The Fix&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;I added a simple middleware in Next.js to normalize the path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   if (url.pathname.includes('%5b') || url.pathname.includes('%5d')) {
    const normalizedPath = url.pathname
      .replace(/%5b/g, '%5B')
      .replace(/%5d/g, '%5D');

    url.pathname = normalizedPath;

    return NextResponse.rewrite(url);
  }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, any lowercase &lt;code&gt;%5b&lt;/code&gt; or &lt;code&gt;%5d&lt;/code&gt; is rewritten back to uppercase, and Next.js can resolve the chunks.&lt;/p&gt;




&lt;h4&gt;
  
  
  🛠 &lt;strong&gt;Debug with cURL&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;After fixing the encoding in middleware (replacing %5b → %5B and %5d → %5D), I try to &lt;strong&gt;verify whether the chunk is correctly served&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   curl -v http://localhost:5000/_next/static/chunks/app/feature/%5bworkd_id%5d/listing/%5bdocument_id%5d/extraction/page-638a1fa4c352c07e.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;-v → verbose mode, shows both headers and body.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the fix is correct, will should see a &lt;code&gt;200 OK&lt;/code&gt; response with headers like:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   HTTP/1.1 200 OK
   Content-Type: application/javascript; charset=utf-8
   Cache-Control: public, max-age=31536000, immutable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;…and the body will be minified JavaScript.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the response is &lt;code&gt;404 Not Found&lt;/code&gt;, the chunk is &lt;strong&gt;still not being resolved&lt;/strong&gt; correctly (likely an encoding issue remains).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Lessons Learned&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Bugs are not always in your code — infra can surprise you.&lt;/li&gt;
&lt;li&gt;URL encoding might look trivial, but consistency matters when loading static chunks.&lt;/li&gt;
&lt;li&gt;Next.js middleware can be a lifesaver for defensive fixes like this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Have you ever faced a similar &lt;code&gt;environment-only&lt;/code&gt; bug? I’d love to hear your story.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>🎯 Don’t Forget Your Git Identity: A Must-Do When Starting a New Project</title>
      <dc:creator>alfanfauzy</dc:creator>
      <pubDate>Tue, 10 Jun 2025 07:49:17 +0000</pubDate>
      <link>https://forem.com/alfanfauzy/dont-forget-your-git-identity-a-must-do-when-starting-a-new-project-256o</link>
      <guid>https://forem.com/alfanfauzy/dont-forget-your-git-identity-a-must-do-when-starting-a-new-project-256o</guid>
      <description>&lt;h2&gt;
  
  
  🧠 Introduction
&lt;/h2&gt;

&lt;p&gt;Starting a new job or contributing to a fresh project? One of the most overlooked steps is setting up your &lt;strong&gt;&lt;em&gt;Git config&lt;/em&gt;&lt;/strong&gt;—especially your name and email. If you skip it, your commits might be misattributed, or worse, tied to the wrong identity.&lt;/p&gt;

&lt;p&gt;In this post, I’ll walk you through the &lt;strong&gt;importance of Git config&lt;/strong&gt;, what happens if you ignore it, and how to set it up correctly using &lt;em&gt;&lt;code&gt;--local&lt;/code&gt;, &lt;code&gt;--global&lt;/code&gt;,&lt;/em&gt; and &lt;em&gt;&lt;code&gt;--system&lt;/code&gt;&lt;/em&gt; scopes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 Why Git Config Matters
&lt;/h2&gt;

&lt;p&gt;Every Git commit has two important fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Author&lt;/code&gt;&lt;/strong&gt;: your name and email address&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Committer&lt;/code&gt;&lt;/strong&gt;: the person who actually applied the commit (often the same)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don’t configure your Git identity, Git might fallback to a system default or nothing at all. This can cause:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commits linked to the wrong email (especially if you're on a shared or borrowed machine)&lt;/li&gt;
&lt;li&gt;Inability to link commits to your GitHub profile (leading to missing contributions)&lt;/li&gt;
&lt;li&gt;Inconsistent commit history in team projects&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠 Git Config Scopes: &lt;code&gt;--local&lt;/code&gt; vs &lt;code&gt;--global&lt;/code&gt; vs &lt;code&gt;--system&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;code&gt;--local&lt;/code&gt; &lt;strong&gt;&lt;em&gt;(most specific)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configuration is stored &lt;strong&gt;in the current Git repository.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Use this when you're using a &lt;strong&gt;different identity&lt;/strong&gt; for a specific project.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  git config --local user.name "Alfan Fauzy"
  git config --local user.email "alfan@newcompany.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;code&gt;--global&lt;/code&gt; &lt;strong&gt;&lt;em&gt;(user-wide)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configuration is stored &lt;strong&gt;in your user directory&lt;/strong&gt; (&lt;code&gt;~/.gitconfig&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Applies to all repositories you work with &lt;strong&gt;unless overridden&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  git config --global user.name "Alfan Fauzy"
  git config --global user.email "alfan@personal.dev"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;code&gt;--system&lt;/code&gt; &lt;strong&gt;&lt;em&gt;(least common)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configuration is stored in the system-wide Git config file (e.g., /etc/gitconfig).&lt;/li&gt;
&lt;li&gt;Requires &lt;code&gt;sudo/admin access&lt;/code&gt; and applies to &lt;code&gt;all users&lt;/code&gt; on the system.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  sudo git config --system core.editor "vim"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💡 Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always check your Git config when starting a new job or project:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  git config --list --show-origin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;--local&lt;/code&gt; for work/company-related projects, especially when using a different GitHub or GitLab account.&lt;/li&gt;
&lt;li&gt;Avoid &lt;code&gt;--system&lt;/code&gt; unless you're managing shared environments or tooling.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ Quick Setup Guide
&lt;/h2&gt;

&lt;p&gt;Here’s a checklist to run before committing to a new repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # Check current Git config
  git config --list --show-origin

  # Set name and email locally for the repo
  git config --local user.name "Your Name"
  git config --local user.email "your@company.com"

  # Optional: Set your preferred editor
  git config --global core.editor "code --wait"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧵 Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting your Git identity might seem minor, but it's essential for maintaining clean, trackable history in your projects. Before your first commit, take a minute to check and set your Git config—it’ll save you and your team a lot of confusion down the road.&lt;/p&gt;




&lt;p&gt;🔄 Feel free to share this with your team, especially if you're onboarding new developers!&lt;/p&gt;

&lt;p&gt;💬 Have a Git tip to share? Drop it in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>git</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to clone repo from Github</title>
      <dc:creator>alfanfauzy</dc:creator>
      <pubDate>Mon, 13 Jun 2022 03:48:27 +0000</pubDate>
      <link>https://forem.com/alfanfauzy/how-to-clone-repo-from-github-gla</link>
      <guid>https://forem.com/alfanfauzy/how-to-clone-repo-from-github-gla</guid>
      <description>&lt;p&gt;In the last month, my office migrate the Repositories from Gitlab to Github. I try to write this article for sharing and as my documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Disclaimer&lt;/em&gt;&lt;/strong&gt; : I have account in Github before and I use mac Terminal&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1
&lt;/h4&gt;

&lt;p&gt;For the first step, I am install Github via Terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install gh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;wait the process install until see the finished installation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2
&lt;/h4&gt;

&lt;p&gt;Second step, authenticated with Github Account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh auth login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;follow the instruction until authenticate with Github Account&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbda9qi4a52wvo6u0ppo1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbda9qi4a52wvo6u0ppo1.png" alt="Screenshoot gh auth login" width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3
&lt;/h4&gt;

&lt;p&gt;Third step, create &lt;code&gt;ssh-keygen&lt;/code&gt; to set to Github Account so we can clone the repo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file will create in folder &lt;code&gt;/Users/yourname/.ssh/&lt;/code&gt;. From this step will be generate 2 file &lt;code&gt;id_rsa&lt;/code&gt; and &lt;code&gt;id_rsa.pub&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Copy text file from &lt;code&gt;id_rsa.pub&lt;/code&gt; with command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pbcopy &amp;lt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste text info your account Github.&lt;/p&gt;

&lt;h4&gt;
  
  
  Last
&lt;/h4&gt;

&lt;p&gt;After following all step, in the last step. I just clone the repo with command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;repo link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, if you doing this in new computer which is the github/gitlab account didn't setting before. Check with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -T git@gitlab.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Source
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en" rel="noopener noreferrer"&gt;https://docs.github.com/en&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>github</category>
      <category>todayilearned</category>
    </item>
  </channel>
</rss>
