ion icon indicating copy to clipboard operation
ion copied to clipboard

Creating an API doesn't naturally output the URL

Open proevilz opened this issue 1 year ago • 2 comments

If you follow the AWS API tutorial , in step 2 it instructs you to run npx sst dev which in turn should give you the APIGW invoke URL for the API.

image

It doesn't do this - here is what I got in my attempt.

image

I posted this issue within the Discord, and for anyone else who runs into this issue, and I was told you can return the URL in the run() block with something like (not tested this yet)

async run() {
  const api = new sst.aws.ApiGatewayV2("MyApi");
  api.route("GET /", {
    handler: "index.upload",
  });
  api.route("GET /latest", {
    handler: "index.latest",
  });
  return {
    url: api.url
  }
}

proevilz avatar Oct 01 '24 16:10 proevilz