Devin
12/23/2021, 10:00 PMapi.url
to the functions in one pass?
this.api = new sst.Api(this, "Api", {
defaultAuthorizationType: "AWS_IAM",
defaultFunctionProps: {
environment: {
API_URL: this.api.url, // like here
I want to have access to it in a route.
I suppose I can do it just by using addRoutes
?Frank
Frank
sst.Api.URL
, and use it like this:
this.api = new sst.Api(this, "Api", {
defaultAuthorizationType: "AWS_IAM",
defaultFunctionProps: {
environment: {
API_URL: sst.Api.URL,
And internally inside Api
construct, this will be this.api.url
?
2. using a callback
this.api = new sst.Api(this, "Api", {
defaultAuthorizationType: "AWS_IAM",
defaultFunctionProps: {
environment: {
API_URL: (api) => api.url,
@thdxr what do u guys think?Devin
12/24/2021, 1:08 PMDevin
12/24/2021, 2:42 PMaddRoutes
.
// Response routes have API_URL available here
this.api.addRoutes(this, {
"POST /send-message": {
function: {
handler: "src/sendMessage.main",
environment: {
API_URL: this.api.url,
},
},
},
});