<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Frontend Development on LOCRIAN_V Blog</title>
    <link>https://lv-blog.pages.dev/en/tags/frontend-development/</link>
    <description>Recent content in Frontend Development on LOCRIAN_V Blog</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Wed, 23 Apr 2025 14:02:30 +0800</lastBuildDate>
    <atom:link href="https://lv-blog.pages.dev/en/tags/frontend-development/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A Guide to Suffering Through WeChat Mini Program Development</title>
      <link>https://lv-blog.pages.dev/en/posts/programming/wechatapp-development-notes/</link>
      <pubDate>Wed, 23 Apr 2025 14:02:30 +0800</pubDate>
      <guid>https://lv-blog.pages.dev/en/posts/programming/wechatapp-development-notes/</guid>
      <description>&lt;h2 id=&#34;the-auth-interaction-flow-between-a-wechat-mini-program-and-the-backend&#34;&gt;The auth interaction flow between a WeChat Mini Program and the backend&lt;/h2&gt;
&lt;p&gt;The core flow of WeChat Mini Program login: the mini program gets a temporary credential &lt;code&gt;code&lt;/code&gt; → the backend exchanges the &lt;code&gt;code&lt;/code&gt; for an &lt;code&gt;openid&lt;/code&gt; → the backend issues its own JWT to the mini program. Below is the overall flow diagram.&lt;/p&gt;
&lt;pre class=&#34;mermaid&#34;&gt;sequenceDiagram
    participant MP as WeChat Mini Program
    participant WX as WeChat server
    participant GW as gateway
    participant Auth as auth module
    participant User as user-service
    participant DB as lia_user database

    MP-&gt;&gt;WX: wx.login() to get code
    WX--&gt;&gt;MP: returns temporary code
    MP-&gt;&gt;GW: POST /auth/wx-login {code}
    GW-&gt;&gt;Auth: forward the request
    Auth-&gt;&gt;WX: code2session(code)
    WX--&gt;&gt;Auth: returns openid + session_key
    Auth-&gt;&gt;User: OpenFeign to query/create the user
    User-&gt;&gt;DB: query by openid
    DB--&gt;&gt;User: user record (or empty)
    User--&gt;&gt;Auth: return userId
    Auth-&gt;&gt;Auth: generate JWT
    Auth--&gt;&gt;MP: return token + user info
    MP-&gt;&gt;MP: store into Storage
&lt;/pre&gt;
&lt;h3 id=&#34;breaking-down-the-key-points&#34;&gt;Breaking down the key points&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;1. The mini program gets the code (frontend)&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
