<?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>DEV Community: Pop Dase</title>
    <description>The latest articles on DEV Community by Pop Dase (@popdasedev).</description>
    <link>https://dev.to/popdasedev</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4154720%2F0f30c624-7c30-473a-b25a-64d3e9673f1c.jpg</url>
      <title>DEV Community: Pop Dase</title>
      <link>https://dev.to/popdasedev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/popdasedev"/>
    <language>en</language>
    <item>
      <title>Why My Env Variables Were Undefined in Production (Astro + Vite)</title>
      <dc:creator>Pop Dase</dc:creator>
      <pubDate>Thu, 01 Oct 2026 15:34:43 +0000</pubDate>
      <link>https://dev.to/popdasedev/why-my-env-variables-were-undefined-in-production-astro-vite-1ac1</link>
      <guid>https://dev.to/popdasedev/why-my-env-variables-were-undefined-in-production-astro-vite-1ac1</guid>
      <description>&lt;p&gt;Here is the error I hit on a production build:&lt;/p&gt;

&lt;p&gt;TypeError: Cannot read properties of undefined (reading "API_URL")&lt;/p&gt;

&lt;p&gt;The same code worked perfectly in development. The .env file was there. The variable was defined. And yet, in production, it was undefined.&lt;/p&gt;

&lt;p&gt;This is one of the most common Vite and Astro gotchas. The error message gives you nothing to work with. Here is what is happening and how to fix it.&lt;/p&gt;

&lt;p&gt;The Rule&lt;/p&gt;

&lt;p&gt;Vite only exposes environment variables that are prefixed with PUBLIC_ to the client. Everything else stays on the server.&lt;/p&gt;

&lt;p&gt;PUBLIC_API_URL=&lt;a href="https://api.example.com" rel="noopener noreferrer"&gt;https://api.example.com&lt;/a&gt;&lt;br&gt;
API_SECRET=abc123&lt;/p&gt;

&lt;p&gt;If you try to reference import.meta.env.API_SECRET from a client-side component, it is undefined. Not because the variable is missing, but because Vite deliberately hides it. This is a feature, not a bug — it prevents you from shipping an API key to every visitor.&lt;/p&gt;

&lt;p&gt;The Symptom&lt;/p&gt;

&lt;p&gt;· Your .env defines API_KEY&lt;br&gt;
· Your component calls import.meta.env.API_KEY&lt;br&gt;
· In development, it works&lt;br&gt;
· In production, it is undefined&lt;br&gt;
· Your code throws a TypeError&lt;/p&gt;

&lt;p&gt;Vite is permissive in dev mode. In production, the build step strips out anything not prefixed with PUBLIC_.&lt;/p&gt;

&lt;p&gt;The Fix&lt;/p&gt;

&lt;p&gt;Option 1: Rename the variable.&lt;/p&gt;

&lt;p&gt;If the value is safe to expose:&lt;/p&gt;

&lt;p&gt;PUBLIC_API_URL=&lt;a href="https://api.example.com" rel="noopener noreferrer"&gt;https://api.example.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then reference it with the new name:&lt;/p&gt;

&lt;p&gt;const apiUrl = import.meta.env.PUBLIC_API_URL&lt;/p&gt;

&lt;p&gt;Option 2: Keep it server-side.&lt;/p&gt;

&lt;p&gt;If the value is a secret, move it into an Astro API route at src/pages/api/something.json.ts:&lt;/p&gt;

&lt;p&gt;export const prerender = false&lt;/p&gt;

&lt;p&gt;export async function GET() {&lt;br&gt;
const response = await fetch("&lt;a href="https://api.example.com/data" rel="noopener noreferrer"&gt;https://api.example.com/data&lt;/a&gt;", {&lt;br&gt;
headers: { Authorization: Bearer ${import.meta.env.API_SECRET} }&lt;br&gt;
})&lt;br&gt;
const data = await response.json()&lt;br&gt;
return new Response(JSON.stringify(data))&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Then call /api/something.json from the client. The secret stays on the server.&lt;/p&gt;

&lt;p&gt;The Cloudflare Trap&lt;/p&gt;

&lt;p&gt;Even after fixing the prefix, a second issue often appears. .env files should not be committed to Git. Cloudflare does not read them. Set the same variables in the Cloudflare dashboard under Settings → Environment variables, for Production and Preview. Then trigger a new deployment.&lt;/p&gt;

&lt;p&gt;The General Rule&lt;/p&gt;

&lt;p&gt;· PUBLIC_ prefix: lives on client and server, safe to expose&lt;br&gt;
· Anything else: server only, not safe to expose&lt;/p&gt;

&lt;p&gt;If a value is not prefixed with PUBLIC_, treat it as a secret.&lt;/p&gt;

&lt;p&gt;Originally published on codex-blog-6v6.pages.dev.&lt;/p&gt;

</description>
      <category>astro</category>
      <category>vite</category>
      <category>webdev</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Fixing the tsconfigPaths Error in Astro + Tailwind 4</title>
      <dc:creator>Pop Dase</dc:creator>
      <pubDate>Thu, 01 Oct 2026 12:34:45 +0000</pubDate>
      <link>https://dev.to/popdasedev/fixing-the-tsconfigpaths-error-in-astro-tailwind-4-2n56</link>
      <guid>https://dev.to/popdasedev/fixing-the-tsconfigpaths-error-in-astro-tailwind-4-2n56</guid>
      <description>&lt;p&gt;If you are building an Astro site with Tailwind 4 and your build fails with this error:&lt;/p&gt;

&lt;p&gt;[&lt;a class="mentioned-user" href="https://dev.to/tailwindcss"&gt;@tailwindcss&lt;/a&gt;/vite:generate:build] Missing field &lt;code&gt;tsconfigPaths&lt;/code&gt; on BindingViteResolvePluginConfig.resolveOptions&lt;/p&gt;

&lt;p&gt;You are not alone. This is a compatibility break between Vite 8 (which ships Rolldown) and the &lt;code&gt;@tailwindcss/vite&lt;/code&gt; plugin. Here is what is happening and how to fix it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codex-blog-6v6.pages.dev/blog/fixing-tsconfigpaths-astro/" rel="noopener noreferrer"&gt;Read the full article on my blog →&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://codex-blog-6v6.pages.dev/blog/fixing-tsconfigpaths-astro/" rel="noopener noreferrer"&gt;codex-blog-6v6.pages.dev&lt;/a&gt;. Follow along there for more notes on Astro, tooling, and deployment.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>astro</category>
      <category>tailwindcss</category>
      <category>vite</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
