sst / ion

SST v3
https://sst.dev
MIT License
1.45k stars 189 forks source link

Nextjs resource URL is not in the environment #733

Open dmeehan1968 opened 1 month ago

dmeehan1968 commented 1 month ago

SST generates SST_RESOURCE_* environment variables for any created resources, and adds definitions for these to the sst-env.d.ts file, so they are accessible from Resource (import { Resource } from "sst").

In my case my app is called Dashboard (new sst.aws.Nextjs('Dashboard', ...), and sst-env.d.ts contains

Dashboard: {
  type: "sst.aws.Nextjs"
  url: string
}

However, there is no SST_RESOURCE_Dashboard in the Nextjs environment (I tried logging from middleware, route and page handlers (RSC)).

jayair commented 1 month ago

Out of curiosity how come you are trying to access it through `SSTRESOURCE*?

dmeehan1968 commented 1 month ago

Out of curiosity how come you are trying to access it through `SSTRESOURCE*?

Because of the other issue I have with my Nextjs being in a subdirectory from sst root. That breaks the types generated to allow it to be referenced via Resource.