<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Seito Horiguchi on Medium]]></title>
        <description><![CDATA[Stories by Seito Horiguchi on Medium]]></description>
        <link>https://medium.com/@seito-horiguchi?source=rss-63f6599257eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SqrAcZ2WyfqwYPyT</url>
            <title>Stories by Seito Horiguchi on Medium</title>
            <link>https://medium.com/@seito-horiguchi?source=rss-63f6599257eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:47:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@seito-horiguchi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[5 Steps to host a static web page on GitHub]]></title>
            <link>https://seito-horiguchi.medium.com/5-steps-to-host-a-static-web-page-on-github-09b8711dcf5a?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/09b8711dcf5a</guid>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[hosting]]></category>
            <category><![CDATA[vites]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 16:12:03 GMT</pubDate>
            <atom:updated>2024-04-25T16:40:55.055Z</atom:updated>
            <content:encoded><![CDATA[<p>GitHub, constantly updated, has recently made hosting easy and allows you to set up a custom domain. From an engineering point of view, it may be easier than renting a server. Simple static pages can be created quickly and easily. It also supports custom domains and HTTPS!</p><p>This article explains how to host a static page using GitHub. Please note that we will start with the assumption that you have already purchased a domain name and have the coding data for your website in the GitHub repository.</p><p>What we used this time<br>- GitHub Actions, GitHub Pages<br>- Vite<br>- Google Domains</p><p>In fact, we hosted our own website with this.<br><a href="https://bug-fix.org/">https://bug-fix.org/</a></p><p>Please note that hosting on GitHub Pages requires either an upgrade to the Enterprise Plan (paid) or that the repository is Public. Please choose one or the other, depending on your situation.</p><h3>1. Set up your domain on GitHub 1/2</h3><p>Set up a purchased domain on GitHub. Go to the account setup page (<a href="https://github.com/settings/pages">https://github.com/settings/pages</a>) and click the “Add a domain” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQxK8M5JkxPony5JGpotPQ.png" /></figure><p>Enter the domain you purchased in the “What domain would you like to add?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQVojSeXPZ4qPs7bcDJvFQ.png" /></figure><p>You will then be redirected to the “Add a verified domain” page. Copy and write down the TXT record information in 1 and 2, leave this page open, and move on to the domain service side of the setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ryMQTVwxhCle_Rbo5doew.png" /><figcaption>*If you are considering transferring a domain name from some hosting service rather than acquiring a new one, you will need to deactivate the domain name from that hosting service first.</figcaption></figure><h3>2. Set up DNS for the purchased domain</h3><p>This is the process of setting up the DNS for the domain you have purchased and connecting it to GitHub. After this, GitHub will authenticate the domain, and by doing so, GitHub will recognize that you are the owner of the domain.</p><p>In this case, we purchased the domain from Google Domains, so we will show you how to do this on their management screen. Although the UI may be different, the DNS setup procedure is generally the same for all services.</p><p>First, go to the domain management page (<a href="https://domains.google.com/registrar/">https://domains.google.com/registrar/</a>) and select any domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhRHZMTo8MyRO3LLJj-TIA.png" /><figcaption>Since I am a Japanese user, this article often uses captured images in Japanese sorry. I will provide the English translation in blue instead.</figcaption></figure><p>Select “DNS” from the left side menu and click the “Manage Custom Records” button. Select “DNS” from the left side menu and click the “Manage Custom Record” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QxgvaSw4burdqDMyNFY1w.png" /></figure><p>This will take you to a page labeled “Resource Records.” Regarding the input screen in 1, you can enable access from GitHub’s IP address here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVWX4eKWFUy9k8udIjEiFg.png" /></figure><p>The IP addresses of GitHub in the A record are the following four at the time of writing (Apr 26, 2024).</p><pre>185.199.108.153<br>185.199.109.153<br>185.199.110.153<br>185.199.111.153</pre><p>The latest information is available on the official page, so we recommend you check the information here.</p><p><a href="https://docs.github.com/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site">Managing a custom domain for your GitHub Pages site - GitHub Docs</a></p><p>Let’s go back to the record setup screen again and explain the part about input field 1…<br>The hostname can be left blank because any domain will be set by default. <br>Type refers to the type of record. In this case, “A” is set. TTL is set to 3600, meaning one hour.<br>And set the data to the IP address of GitHub, as mentioned earlier. Click the “Add more records” link to increase the number of input fields and set four.</p><p>Next, let’s look at input field 2. Here, enter the TXT record information that you wrote down on the GitHub setup screen. The hostname will be followed by “.domain-name” added at the end of the hostname, like “xxx.domain-name”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_x6kDqE2VGWDzX-Txn7Thg.png" /></figure><p>Click the “Save” button in the lower right corner to complete the DNS configuration for the domain.</p><p>And you can verify the result by inputting the command dig {your domain name} + noall + answerin CLI. It succeeds if the following values return.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTNC8PiZQb4EBggj8hojRA.png" /></figure><h3>3. Set up your domain on GitHub 2/2</h3><p>Next, go back to GitHub and complete the domain verification. On the screen that is still open, click the “Verify” button at 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBOevZvm84jscZ_L6137IQ.png" /></figure><p>If the configuration is successful, it will be added to the “Verified domains” section with the label “Verified”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUNrziXYCw8MkyABZwRrEw.png" /></figure><p>You will get a message saying that it will take up to 24 hours, but in my case, it took only a couple of minutes. That’s very fast.</p><h3>4. Build and Hosting Settings in the Repository</h3><p>Now comes the final stage! Click on the tab menu “Settings” in the upper right corner of the GitHub repository page where the website data is stored, then click on “Pages” in the left side menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gpQb5VRzLiaOxVubwslOhg.png" /></figure><p>Under “Source,” select the build method. Deploy from a branch” is simple and may be fine, especially if you are creating static pages that do not need to be built. In that case, set “Branch” below to any branch. When data is pushed to the branch set here, it will be hosted immediately with the directory structure as it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tn-kVZ1GxPhx-FZKUk6vUw.png" /></figure><p>If you are using Webpack, Vite, Next.js, etc., you will need to build them, so select “GitHub Actions”. Two menus will appear. Since this is a static site, click the “Configure” button under “Static HTML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7hcCn2b-0VwSWqXwdh37Q.png" /></figure><p>This will take you to the `/.github/workflows/static.yml` edit screen. The settings described here will be executed at build time using GitHub Actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu_fXnOoL2FsNvkRJoSCMw.png" /></figure><p>The contents will vary depending on the framework you are using. In the case of Vite, there is a specific description on the official page, so you can almost copy and paste.</p><p><a href="https://ja.vitejs.dev/guide/static-deploy.html#github-pages">https://vitejs.dev/guide/static-deploy.html#github-pages</a></p><p>This is all of the code.</p><pre># Simple workflow for deploying static content to GitHub Pages<br>name: Deploy static content to Pages<br><br>on:<br>  # Runs on pushes targeting the default branch<br>  push:<br>    branches: [&quot;main&quot;]<br><br>  # Allows you to run this workflow manually from the Actions tab<br>  workflow_dispatch:<br><br># Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages<br>permissions:<br>  contents: read<br>  pages: write<br>  id-token: write<br><br># Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.<br># However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.<br>concurrency:<br>  group: &quot;pages&quot;<br>  cancel-in-progress: false<br><br>jobs:<br>  # Single deploy job since we&#39;re just deploying<br>  deploy:<br>    environment:<br>      name: github-pages<br>      url: ${{ steps.deployment.outputs.page_url }}<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@v4<br>      - name: Setup Pages<br>        uses: actions/configure-pages@v4<br>      - name: Upload artifact<br>        uses: actions/upload-pages-artifact@v3<br>        with:<br>          # Upload entire repository<br>          path: &#39;./dist&#39;<br>      - name: Deploy to GitHub Pages<br>        id: deployment<br>        uses: actions/deploy-pages@v4</pre><p>Let me emphasize the important parts in two places just in case.</p><ul><li>`on.push.branches` … The name of the branch you are hosting. The default is main, but if you change the branch name, change this as well.</li><li>`jobs.deploy.steps.with.path` … The path to the output directory of the data to be built when npm run build is executed. Default is `. /dist` by default, but if you have changed it, change it here as well.</li></ul><p>When you have finished making changes, click “Commit changes…” in the upper right corner of the screen. in the upper right corner of the screen.<br>This will create the file “/.github/workflows/static.yml” on the GitHub page, and commit and push the file, so pull it locally as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPBSRKrJpri8k82fgyD5EA.png" /></figure><p>You will return to the GitHub repository page. Enter the domain name in the “Custom domain” entry field and click the “Save” button. If the process up to this point has been successful, you can Save without any problems, but please note that an error will occur if you make a mistake somewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqnbrJPUF5xgzPLeFPHUeg.png" /></figure><h3>5. Hosting with GitHub Actions</h3><p>After all this is done, let’s push the data to the branch you have set up (main by default). If successful, a “Visit site” button will appear on the Pages screen of the repository, which you can access from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnnxKdS-IFNoy1IYpmWROA.png" /></figure><p>If you want to know whether the deployment was successful or not, and if so, what was the cause, you can view the history in the “Actions” tab of the repository. You can also click on the history of failures to see the error details and logs, which can be used as hints to fix the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPNhdHQvEj-bAObgQOuJRQ.png" /></figure><h3>If it does not work…</h3><p>Even if you proceed as described here, it may not work as expected.</p><ul><li>When setting a custom record, the message “IPv4 address is invalid” is displayed</li><li>The above command does not return as expected.<br>In such cases, please try the following.</li></ul><p>First, set the DNS record type to “ALIAS or ANAME” instead of “A” when setting the custom record.<br>Then set “TTL” to 3600 and “DNS record value” to “USERNAME.github.io”.<br>For example, in my case, my GitHub user name is “seito-developer”, so the DNS record value is “seito-developer.github.io”.<br>Below is an example of the input on the administration screen when setting up with a Google domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2K8TMDXVAt5fy12a8qwzBA.png" /></figure><p>This is what GitHub’s official.</p><p><a href="https://docs.github.com/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site">Managing a custom domain for your GitHub Pages site - GitHub Docs</a></p><p>Then again, enter the desired domain in “Custom domain” in “GitHub Pages” and authenticate again. This will take a few minutes, but if all goes well, you will see a “DNS check successful” message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2HFXG5vY0ki7TEf7ecQtw.png" /></figure><p>Then make some changes again and update the repository by pushing to the main branch. This will trigger a GitHub Action and deploy automatically.<br>You can make any changes you want (e.g., change one character in the README).</p><p>Now, when you access your domain, it should reflect the changes. (It may take a few minutes)</p><h3>Do you wanna set up the subdomain “www,” too?</h3><p>In addition, we will also specify here how to set up a www subdomain.<br>This will make it possible to automatically redirect accesses to “<a href="https://www.bug-fix.org/">https://www.bug-fix.org/</a>&quot; to “<a href="https://bug-fix.org/">https://bug-fix.org/</a>&quot; and so on.</p><p>The setting method is simple. Set the subdomain “www” in the same way as setting a DNS record. Access the administration screen of the domain management service and set the custom record settings as follows.</p><ul><li>Host name: www</li><li>DNS record type: CNAME</li><li>TTL: 3600</li><li>DNS record value: USERNAME.github.io (*)</li></ul><p>For example, in my case, my GitHub user name is “seito-developer”, so the DNS record value is “seito-developer.github.io”. Below is an example of the input on the administration screen when setting up with a Google domain.</p><p>After this, you need to access “GitHub Pages” again, authenticate with “Custom domain” &amp; update the repository, push, and run the GitHub Action. This process should be automatic, but it is a good idea to check it visually as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2HFXG5vY0ki7TEf7ecQtw.png" /></figure><p>Create CNAME” is automatically created and pushed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vy4HNkWNVdOUM3DrEWXaZA.png" /></figure><p>That’s it, thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09b8711dcf5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to resolve the TypeScript error of“Property ‘foo’ does not exist on type ‘HTMLElement’.”]]></title>
            <link>https://seito-horiguchi.medium.com/how-to-resolve-the-typescript-error-of-property-foo-does-not-exist-on-type-htmlelement-19bb9b7bfbc2?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/19bb9b7bfbc2</guid>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[typescript-tips]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 03:53:10 GMT</pubDate>
            <atom:updated>2024-03-30T03:53:10.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>What happened?</h3><p>I’ve coded like this with TypeScript.</p><pre>const blob = new Blob([response.data], { type: &quot;application/zip&quot; });<br>const url = window.URL.createObjectURL(blob);<br>const a = document.createElement(&quot;a&quot;);<br>a.href = url;<br>a.download = &quot;files.zip&quot;;<br>document.body.appendChild(a);<br>window.URL.revokeObjectURL(url);<br>document.body.removeChild(a);</pre><p>This is a program that a user can upload a CSV file, convert it to JSON, and download it as a zip file. But please only look at this part.</p><pre>const a = document.createElement(&quot;a&quot;);<br>document.body.appendChild(a);</pre><p>This code is making the DOM element of `&lt;a&gt;` and adding it to `&lt;body&gt;.` The program like this is not unique but unusual, right?</p><p>But I got the TypeScript error.</p><pre>Property &#39;appendChild&#39; does not exist on type &#39;HTMLElement&#39;.</pre><p>The error said “ `appendChild` tried to access to an object of HTMLElement, `document.body`, but`document.body` doesn&#39;t have such a property or a method”.</p><p>But we know `appendChild` is a very common method in HTMLElement, hmm….</p><h3>How did I resolve it?</h3><p>As a summary, I just used append instead of appendChild .</p><pre>document.body.appendChild(a); //NG<br>document.body.append(a); //OK</pre><p>You may know append is common in jQuery, but it is now common in Vanilla JavaScript too.</p><p>MDN says their differences are as follows.</p><ul><li>append can also accept a string, but appendChild can only do a Node object.</li><li>append doesn’t have a return value, but appendChild can return an added Node object.</li><li>append can accept multiple Node objects and strings, but appendChild can accept only ONE Node object.</li></ul><p><a href="https://developer.mozilla.org/ja/docs/Web/API/Node/appendChild">https://developer.mozilla.org/docs/Web/API/Node/appendChild</a></p><p>Totally append looks more powerful than appendChild. (But I don’t know what the error happened this time because my code surely takes only one Node object as an argument…)</p><p>BTW, I asked ChatGPT before reaching this solution, but all of its advice didn’t work.</p><ul><li>Cast by `any` or `HTMLElement`</li><li>Add `if(document?body){ … }`</li><li>Re-install `node_modules`</li><li>Change the settings of `tsconfig.json`</li><li>Reboot your IDE</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19bb9b7bfbc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 items to check if you get a “Permission denied” message when running Docker]]></title>
            <link>https://seito-horiguchi.medium.com/5-items-to-check-if-you-get-a-permission-denied-message-when-running-docker-df4368cfaebb?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/df4368cfaebb</guid>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Fri, 16 Feb 2024 12:45:56 GMT</pubDate>
            <atom:updated>2024-02-16T12:47:23.228Z</atom:updated>
            <content:encoded><![CDATA[<p>When using Docker to docker compose up , docker compose build, makemigrations, migrate, etc., the error Permission denied may occur.<br>There may be multiple reasons for this error.</p><h3>1. The directory or file may not be created in the Docker image in the first place.</h3><p>The Dockerfile may not contain the code to generate the target directory or file. To generate a directory or file at build time, add the following command to the Dockerfile.</p><pre># Create a directory<br>RUN mkdir &lt;Your Directory Name&gt;<br><br># Create a file<br>RUN touch &lt;Your File Name&gt;</pre><h3>2. The path may be wrong</h3><p>The directory or file exists, but the path is wrong… This error also seems to occur when there is a directory or file but the path is wrong.<br>For example, the following is a piece of code that expects /usr/src/app to be the project directory, and a directory and file named test to be created directly under it in the container. If these do not match exactly, an error may occur.</p><pre>ENV APP_HOME=/usr/src/app<br><br>RUN mkdir $APP_HOME/test</pre><pre>services:<br>  app:<br>    build: ./<br>    working_dir: /usr/src/app/<br>    volumes:<br>        - .:/usr/src/app</pre><h3>3. You may not have the access permission</h3><p>If a directory or file is created and the path is correct, but Permission denied is displayed, you may not have permission to access the directory or file. For example, access permissions can be defined in the Dockerfile as follows.</p><pre>... omission ...<br><br>RUN addgroup -S myuser &amp;&amp; \<br>    adduser -S myuser -G myuser &amp;&amp; \<br>    chown -R myuser:myuser $APP_HOME<br>USER myuser</pre><p>This command roughly describes the following operations one line at a time.</p><ol><li>Create a group named myuser</li><li>Create a user named myuser , and add the myuseruser to the myuser group</li><li>Grant the myuser group and the myuser user read/write permissions to the $APP_HOME directory.</li><li>Perform a series of operations as the myuser user</li></ol><p>While the above is an approach to manipulate directories and files by granting privileges to users, the following is an approach to directly manipulate directory and file access privileges.</p><pre>RUN chmod u+w $APP_HOME/test</pre><p>The commandchmod use the same syntax as the Linux commands that operate on the command line.</p><h4>Cases where authorization cannot be granted</h4><p>Unfortunately, there are cases where access rights cannot be granted even after performing these operations. When running Docker containers on virtual servers (e.g. Amazon EC2 instances), Docker operations and virtual server security settings are located on different layers.</p><p>If those virtual server settings (network access settings, security groups, firewall settings, etc.) affect the accessibility of Docker containers, they cannot be operated from Docker. In that case, you need to talk to the server administrator and ask for authorization.</p><h3>4. It may not be necessary</h3><p>Is writing to that directory/file necessary in the first place?” If it is unnecessary, you can eliminate the writing process to the directory/file.<br>If it is unnecessary, you can eliminate the writing process to the directory/file.</p><h3>5. Others</h3><p>The changed settings may not be reflected. For example, docker compose build can be run with the option docker compose build --no-cache to clear the cache.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df4368cfaebb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Be careful when implementing Next.js SSR in a Docker environment.]]></title>
            <link>https://seito-horiguchi.medium.com/be-careful-when-implementing-next-js-ssr-in-a-docker-environment-715a6d4969e3?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/715a6d4969e3</guid>
            <category><![CDATA[ssrs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 10:07:15 GMT</pubDate>
            <atom:updated>2023-11-15T10:12:03.282Z</atom:updated>
            <content:encoded><![CDATA[<p>I was implementing SSR for Next.js in a Docker environment and got really stuck in the middle, so I’m leaving the solution as a reminder.<br>This may be useful for people like you.</p><ul><li>You are using Docker and have separate containers for front-end and back-end</li><li>Implement SSR or SSG in Next.js</li></ul><p>My development environment is as follows</p><ul><li>Front-end: Next.js (v13.1.6)</li><li>Backend: Python, Django REST framework (v3.13.1), PostgreSQL (v14)</li></ul><p>Docker containers are set up and developed for the frontend and backend respectively, and Nginx is deployed on the backend.</p><h3>Background</h3><p>We were developing without using SSR until the middle of the project, but we had to run SSR on the top page because of the need to implement additional functions.<br>The frontend was developed on localhost:3000, the backend on localhost:8000, and we added the following code…</p><pre>export async function getServerSideProps(context:any) {<br> const { data } = await axios.get(“http://localhost:8000/api/foo/&quot;);<br> return {<br>   props: {<br>     data: data<br>   },<br> };<br>}</pre><p>I can no longer access localhost and it returns a 500 error.<br>The error message then is as follows.</p><pre>Connect ECONNREFUSED 127.0.0.1:8000</pre><p>After a lot of research, it looks like there are two causes that need to be resolved in two steps.</p><h3>Cause and Solution 1</h3><p>So, the first step.<br>First, when SSR is used in a Docker environment, it is necessary to specify the port on the container side, not on the host side. So, rewrite the API call destination in such a way.<br>For example, if you use Nginx on the backend, the <strong>docker-compose.yml</strong> might have the following description.</p><pre>version: &quot;3.9&quot;<br><br>services:<br>  app:<br>    ...(Omitted)<br>  <br>  db:<br>    ...(Omitted)<br>  <br>  nginx:<br>    build:<br>      context: ./nginx<br>      dockerfile: Dockerfile<br>    ports:<br>      - 8000:80<br>    ...(Omitted)</pre><p>Currently, Nginx’s service name is Nginx, listening on port 80, so the following is used.</p><pre>// Before <br>const { data } = await axios.get(&quot;http://localhost:8000/api/foo/&quot;);<br> <br>// After<br>const { data } = await axios.get(&quot;http://nginx:80/api/foo/&quot;);</pre><p>This solves the first error.<br>When accessing the local host, the previous error message no longer appears.<br>But now I get the following error.</p><pre>Error: getaddrinfo ENOTFOUND nginx</pre><h3>Cause and Solution 2</h3><p>This error seems to be caused by using multiple containers, each on a different network.<br>Therefore, we need to modify the container configuration so that the front end and the back end are on the same network.</p><p>First, add the <strong>networks</strong> setting to the backend’s <strong>docker-compose.yml</strong>.</p><pre>version: &quot;3.9&quot;<br><br>services:<br>  app:<br>    ...(Omitted)<br>    networks:<br>      - front<br>      - back<br><br>  db:<br>    ...(Omitted)<br>    networks:<br>      - back<br>  <br>  nginx:<br>    ...(Omitted)<br>    networks:<br>      - front<br><br>networks:<br>  front:<br>    external: false<br>  back:<br>    external: false</pre><p>Here we define two networks, <strong>front</strong> and <strong>back</strong> respectively, meaning that nginx connects to <strong>front</strong>, db connects to <strong>back</strong>, and app connects to both <strong>front</strong> and <strong>back</strong> networks.<br>Defining this will allow communication between containers.<br>The <strong>external: false </strong>at the end indicates that these networks <strong>front</strong> and <strong>back</strong> are newly defined here.</p><p>If you want to use a network that is already defined in an external container, you can specify the name of that network and set <strong>external: true</strong> (more on this later). (More details on this later).</p><p>Then, add the <strong>networks</strong> setting to the front-end <strong>docker-compose.yml</strong> as well.</p><pre>services:<br>  app:<br>    ...(Omitted)<br>    networks:<br>      - foo_font<br><br>networks:<br>  foo_font:<br>    external: true</pre><p>First, let’s explain <strong>foo_font</strong> (it’s a bit complicated).<br>We defined new networks <strong>front</strong> and <strong>back</strong> earlier, but since we need to use the same networks, we will configure them to use the existing ones.</p><p>So we will use the same network name that we defined for nginx in the backend container.<br>So the network name is <strong>front</strong>? But it is not.<br>By default, the project name (directory name) is used as the network name prefix, which is <strong>project_front</strong>.<br>So, if the directory name of this backend is, for example, <strong>foo</strong>, then <strong>foo</strong> will be prefixed with <strong>foo_front</strong>.</p><p>You can also check the network name with this command.</p><pre>docker network ls</pre><p>In addition, since we just defined a new network, we set <strong>external: false</strong> at the bottom of <strong>docker-compose.yml</strong> in the networks configuration.</p><p>This solved the problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=715a6d4969e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Allow 301 response in AWS Elastic Beanstalk]]></title>
            <link>https://seito-horiguchi.medium.com/allow-301-response-in-aws-elastic-beanstalk-735cebc31029?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/735cebc31029</guid>
            <category><![CDATA[elastic-beanstalk]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Wed, 31 Aug 2022 15:45:53 GMT</pubDate>
            <atom:updated>2022-08-31T15:45:53.889Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>The other day, I deployed a web app on AWS Elastic Beanstalk.<br>I thought I had wholly defeated it after battling several errors, but when I looked at the dashboard, the Health status was “Severe”, and something seemed wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQ2cWjMSeD6l3c2KOYHKlg.png" /></figure><p>But when I look at the logs, there are no errors, I can access the domain…</p><p>I wondered what was wrong, so I contacted AWS support and got this answer.</p><pre>From curl operation, we could see that response code is “301”. <br>I would like to inform you that the Environment’s Load Balancer is expecting HTTP 200 as response code but the Application is returning HTTP 301. </pre><pre>Redirection configured on the backend can result in a 301 or 302 response code, resulting in failed health checks even if your application is working fine. </pre><pre>Therefore, due to mismatch in the success code the health failing with”Target.ResponseCodeMismatch”[2]. As as result, health is showing as severe.</pre><p>In short, the cause is that a 301 response is being returned and this is being recognized as some kind of error. If you make Elastic Beanstalk recognize that this response is not an error, you can solve the problem.<br>So I tried throwing a request with curl and got a response that looked good.</p><pre>curl -Ivk {myAppDomain.ap-northeast-1.elasticbeanstalk.com}</pre><pre>*   Trying xx.xxx.xxx.xx:80...<br>* Connected to {myAppDomain.ap-northeast-1.elasticbeanstalk.com}  (xx.xxx.xxx.xx) port 80 (#0)</pre><pre>&gt; HEAD / HTTP/1.1<br>&gt; Host: {myAppDomain.ap-northeast-1.elasticbeanstalk.com} <br>&gt; User-Agent: curl/7.79.1<br>&gt; Accept: /<br>&gt; Mark bundle as not supporting multiuse<br>&lt; HTTP/1.1 301 Moved Permanently<br>HTTP/1.1 301 Moved Permanently</pre><p>301 response means redirect. It seems to be affected because I have set up my own domain and configured HTTP to HTTPS redirects, etc.</p><h3>Solution</h3><p>You can configure the load balancer to accept 301 responses.<br>Specifically, you do the following</p><ol><li>Go to “Configuration”, “Load balancer”, and click “Edit”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLqC8oH8mMyIVX8Bbz_6dw.png" /></figure><p>2. Go to “Processes”, check the process of “Port: 80, Protocol: HTTP“, go to “Action” and click “Edit“</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssGlVF7PoLrdQWaRCcOXSQ.png" /></figure><p>3. Add 301 to “HTTP code”; (If 200 is not present, add it as well. In that case, separate it with a comma without space, like 200,301.) Then press the Save button to close.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d78KChn_cEDOSBRZ-ave5Q.png" /></figure><p>4. Finally, do not forget to press “Apply” and then “Contiune” at the bottom of the page. If you don’t do this, it will not be adopted. That’s all!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGfYCRv4ziFb--reFtS-Dg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=735cebc31029" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To import spreadsheet or excel data into a db file in SQLite format]]></title>
            <link>https://seito-horiguchi.medium.com/to-import-spreadsheet-or-excel-data-into-a-db-file-in-sqlite-format-4be126d74ea2?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be126d74ea2</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sqlite]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 19:11:54 GMT</pubDate>
            <atom:updated>2022-03-03T07:42:33.198Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently prepared a SQLite DB for my Flutter application, but I wanted to use the data I had entered in the spreadsheet beforehand.</p><h3>Prerequisite information</h3><ul><li>Importing directly from a spreadsheet or Excel is quite cumbersome, so let’s make it a CSV file!</li><li>It is not possible to append CSV data to an existing db file. You need to create a new table.</li><li>I’m using a Mac PC, so we are showing you how to do this.</li></ul><h3>1. Create a db file and connect to SQL</h3><p>In the beginning, you can start a command line (Terminal on Mac), create a db file, and connect to SQL at the same time.</p><pre>sqlite3 {file name}.db</pre><p><strong>Example)</strong></p><pre>sqlite3 database.db</pre><p>（If successful, you will see “sqlite &gt;” on the command line.）</p><pre>sqlite &gt;</pre><h3>2. Create a new table</h3><p>Next, you can create a new table.</p><pre>create table {table name}(<br>{column name} {column type},<br>{column name} {column type},<br>{column name} {column type} ...);</pre><p><strong>Example)</strong></p><pre>create table myTable(<br>id integer,<br>name text,<br>imagePath text,<br>description text);</pre><p>If successful, you can see the table created with the command `.schema {table name}`.</p><pre>.schema {table name}</pre><h3>3. Import a CSV file</h3><p>At last, you can use the command `.import` to specify the csv file you want to import and the name of the table you just created to import.</p><pre>.import {path to csv file} {table name}</pre><p><strong>Example)</strong></p><pre>.import /Users/taro/Documents/database.csv myTable</pre><p>If successful, you can list the imported data by inputting `SELECT * from {any table name};`.</p><pre>SELECT * from {any table name};</pre><p>When you are done, you can disconnect to SQL by the command “.quit” or “ctrl + C”.</p><pre>.quit</pre><h3>If you meet any errors…</h3><p>There is a desktop app GUI called <a href="https://sqlitebrowser.org/">DB Browser for SQLite</a> that allows you to view db files on the app.<br>It also seems to have a csv import function. If you don’t have a lot of columns, this will be easier for you.</p><p>BTW, in the case of the Flutter app, if the db file contains extra data such as header information, or if the data types do not match perfectly, it will not display anything without throwing an error.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be126d74ea2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Ways to Align Text in Flutter]]></title>
            <link>https://seito-horiguchi.medium.com/3-ways-to-align-text-in-flutter-8bb9af9417ea?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bb9af9417ea</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 17:39:04 GMT</pubDate>
            <atom:updated>2022-02-26T17:40:02.851Z</atom:updated>
            <content:encoded><![CDATA[<p>When you want to left-center, center, or right-align text in Flutter, do you ever have trouble getting it to work the way you want?<br>Depending on the widget you are using, it may or may not work the way you want it to….</p><p>There are several ways to do this, so let’s try one of them.</p><h3>1. TextAlign in Text()</h3><pre>Text(<br> “text”, <br> textAlign: TextAlign.left //Optional property<br>)</pre><p>This is the simplest approach. If this solves the problem, that’s best.</p><h3>2. Align ()</h3><pre>Align(<br> alignment: Alignment.centerLeft, //optional property<br> child: Text(…)<br>)</pre><p>This is an approach for enclosing Text() with Align().</p><h3>3.Container ()</h3><pre>child: Container(<br> alignment: Alignment.centerLeft, //optional property<br> width: double.infinity,<br> child: Text(…)<br>)</pre><p>This is an approach to surround Text() with Container().<br>In some cases, it is better to set `width: double.infinity` in addition to alignment. (If you set this, you can adjust the width limit of the content to the width of your phone.)</p><p>Some cases can be solved with just one of these, others with a combination of them, so give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bb9af9417ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Flutter] How to solve the problem when the build on the actual iPhone fails.]]></title>
            <link>https://seito-horiguchi.medium.com/flutter-how-to-solve-the-problem-when-the-build-on-the-actual-iphone-fails-8b51a7e9b5c3?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b51a7e9b5c3</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 16:37:55 GMT</pubDate>
            <atom:updated>2022-02-26T16:37:55.720Z</atom:updated>
            <content:encoded><![CDATA[<p>The other day, while developing an app in Flutter, I suddenly encountered the following error when I built the app to check it on my iPhone.</p><pre>Unable to prepare iPhone for development.</pre><p>and…</p><pre>iPhone is busy: Fetching debug symbols for iPhone. Xcode will continue when iPhone is finished.</pre><p>I wondered why this was happening since I had been able to build without any problems up until then. I wondered why, but it seems to be an error that occurs when the iPhone OS or Xcode is upgraded.</p><p>The following are all the things I tried before I solved the problem.<br>To be honest, I haven’t been able to identify which ones were effective because I tried many things and before I knew it, the problem was solved.<br>If you’re having the same problem, give it a try! Any of them will solve your problem.</p><ul><li>Run `flutter clean` and `flutter build ios` again</li><li>Wait 5~10 minutes and build again</li><li>Reset the trust between iPhone and Mac PC (Open iPhone -&gt; Settings -&gt; General -&gt; Transfer or Reset iPhone -&gt; Reset -&gt; Reset Location and Privacy), then reconnect and trust again</li><li>Restart Mac PC</li><li>Restart iPhone</li><li>Manually delete an app built in the iPhone once</li><li>Upgrade Xcode</li><li>Upgrade your iPhone’s iOS version.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b51a7e9b5c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make the internet connection of windows 10 available in Parallels]]></title>
            <link>https://seito-horiguchi.medium.com/how-to-make-the-internet-connection-of-windows-10-available-in-parallels-7f1687b65f64?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f1687b65f64</guid>
            <category><![CDATA[virtualization]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[parallels]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Tue, 24 Aug 2021 14:30:06 GMT</pubDate>
            <atom:updated>2021-08-24T14:30:06.850Z</atom:updated>
            <content:encoded><![CDATA[<p>If you use a MacOS PC but wanna use Windows OS, installing Parallels will probably be a best practice.</p><p><a href="https://www.parallels.com/">Application and Desktop Delivery | Parallels RAS</a></p><p>It is the virtualization tool and you can run Windows in your Mac PC.</p><p>But you may be in struggle when you try to connect with internet at the first.</p><p>Today, I’ll show a few solutions which may help you.</p><h3>1. Activate “Shared Network”</h3><p>“Shared Network” shares the internet setting in your Mac to Windows in Parallels.</p><p>As “Shared Network” is the easiest option, although the menu also has others, such as “Wi-Fi”, I don’t recommend them.</p><p>To activate “Shared Network”,</p><ol><li>Click the Parallels menu on your menubar and choose “Configure…</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grzke9OLH7pmsClORFgncg.png" /></figure><p>2. Go to “Hardware” on the top, and go to “Network” on the left side</p><p>3. Choose “Shared Network (Recommended) from “Source:”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHE-D9Sh1dfCTP6jiITVxA.png" /></figure><p>Please don’t forget lock the key on the bottom left finally.</p><h3>2. Invalidate IPv6 setting</h3><p>In one of possibilities, “IPv6 setting” may disturb you from validating your internet.</p><p>If so, please try this 2nd solution!</p><ol><li>Click the Parallels menu on your menubar and choose “Configure…</li><li>Go to “Hardware” on the top, and go to “Network” on the left side</li><li>Click “Advanced…” under “Source:”</li><li>Click “Open Network Preferences…”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kfgwnapg9P2NGZaE8armdg.png" /></figure><p>5. Choose “Shared” on the left side</p><p>6. Choose “IPv6” tab</p><p>7. Uncheck “Enable IPv6 DHCP”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UejXR2c4pQgnIuR5hniFXA.png" /></figure><p>Please don’t forget lock the key on the bottom left finally too.</p><h3>3.Overwrite the authorization setting from Terminal</h3><p>If your internet is not available, I offer this solution.</p><p><strong>Please shutdown Parallels before starting this way just in case.</strong></p><ol><li>Open Terminal app</li><li>Put this command end Enter</li></ol><pre>sudo nano /Library/Preferences/Parallels/network.desktop.xml</pre><p>3. Rewrite a part</p><p>Terminal will output codes like this.</p><pre>&lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt; ...</pre><p>And you can find “UseKextless” part. Please rewrite the number to “0” like this.</p><pre># Before<br>&lt;UseKextless&gt;-1&lt;/UseKextless&gt;<br></pre><pre># After(Expectation)<br>&lt;UseKextless&gt;0&lt;/UseKextless&gt;</pre><p>4. After that, you can save by “Ctrl + X”</p><p>5. Terminal will ask you whether you save it or not. And you can answer Yes by “Y”</p><p>6. You can close them by “Enter”</p><p>After that, you can restart Parallels and its internet will automatically run!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f1687b65f64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to fix errors at deploying React apps with AWS Amplify]]></title>
            <link>https://seito-horiguchi.medium.com/how-to-fix-errors-at-deploying-react-apps-with-aws-amplify-61ba37715e5b?source=rss-63f6599257eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/61ba37715e5b</guid>
            <category><![CDATA[sap]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amplify]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Seito Horiguchi]]></dc:creator>
            <pubDate>Sun, 18 Jul 2021 06:15:50 GMT</pubDate>
            <atom:updated>2021-07-18T09:08:04.099Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi,</p><p>I met a few errors when I tried to deploy a SPA with React and AWS Amplify the other day.</p><p>Let me introduce in this article how I fixed them.</p><p>It may help you if you now have the following errors.</p><ol><li><strong>“ERR_ABORTED 403&quot; </strong>in manifest.json</li><li><strong>“Uncaught SyntaxError: Unexpected token ‘&lt;’“</strong> in index.html</li></ol><p>In these cases, you can try the following solutions.</p><h4>Check “package.json”</h4><p>If <strong>”package.json”</strong> has the code for deploying to<strong> “gh-pages”</strong> in GitHub, it’s better to remove it like this. it may disturb your deploy in AWS</p><pre>“homepage”: “<a href="https://seito-developer.github.io/shadowX">https://user-developer.github.io/p</a>roject_name&quot;</pre><h4>Try “amplify publish” again and verify paths</h4><p>You may be better to try the commands <strong>“amplify publish” </strong>and <strong>“ yarn build”. </strong>The errors sometimes are caused by mistaking paths. you can confirm <strong>paths of href and src</strong> in index.html</p><p>This is a sample and you can find paths in it.</p><pre>&lt;!doctype html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;meta charset=&quot;utf-8&quot;/&gt;&lt;link rel=&quot;icon&quot; <strong>href=&quot;/favicon.ico&quot;</strong>/&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1&quot;/&gt;&lt;meta name=&quot;theme-color&quot; content=&quot;#000000&quot;/&gt;&lt;meta name=&quot;description&quot; content=&quot;Web site created using create-react-app&quot;/&gt;&lt;link rel=&quot;apple-touch-icon&quot; <strong>href=&quot;/logo192.png&quot;</strong>/&gt;&lt;link rel=&quot;manifest&quot; href=<strong>&quot;/manifest.json&quot;</strong>/&gt;&lt;title&gt;React App&lt;/title&gt;&lt;link <strong>href=&quot;/static/css/main.feda3d3d.chunk.css&quot;</strong> rel=&quot;stylesheet&quot;&gt;&lt;/head&gt;&lt;body&gt;&lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;&lt;div id=&quot;root&quot;&gt;&lt;/div&gt;&lt;script&gt; ...... &lt;/script&gt;&lt;script <strong>src=&quot;/static/js/2.3c825274.chunk.js</strong>&quot;&gt;&lt;/script&gt;&lt;script <strong>src=&quot;/static/js/main.69363c5f.chunk.js&quot;</strong>&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</pre><p>Build command for yarn</p><pre>yarn build</pre><p>Deploy command for amplify</p><pre>amplify publish</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61ba37715e5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>