フツーにやろうとしたら結構つまづいたので備忘録的にメモっておきます。 早速ですが、答えから先に書いておきますね --- const authorization = Astro.request.headers.get('authorization') const pieces = authorization?.split(/\s+/g) if(authorization) { if(pieces) { if(pieces[0] === 'Basic') { const buffer = Buffer.from(pieces[1], 'base64') const credentials = buffer.toString() console.log(credentials) const [username, password] = credentials.split(':') if(user
![Astro SSRでBasic認証](https://cdn-ak-scissors.b.st-hatena.com/image/square/312b52dfb14b52aef63e0bcaa7e8cf9e20601db2/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--kJNecX62--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_66%3AAstro%252520SSR%2525E3%252581%2525A7Basic%2525E8%2525AA%25258D%2525E8%2525A8%2525BC%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_37%3A%2525E3%252581%252597%2525E3%252581%25258B%2525E3%252581%25259F%2525E3%252581%252593%2525E3%252581%252586%2525E3%252581%25258D%252Cx_203%252Cy_121%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EtL0FPaDE0R2h5bE15Ym9yc056OVd6WENSRW9jYmRrUUlfYmY1ZGZVeGpOel9vPXM5Ni1j%252Cr_max%252Cw_90%252Cx_87%252Cy_95%2Fv1627283836%2Fdefault%2Fog-base-w1200-v2.png)