sst / sst

Build full-stack apps on your own infrastructure.
https://sst.dev
MIT License
24.07k stars 1.86k forks source link

can't configure timeout and cors on a lambda route for router #5892

Open sockthedev opened 1 month ago

sockthedev commented 1 month ago

the default timeout on the router is 20s, i tried to increase the timeout via the router.route config, like so:

const API_TIMEOUT_SECONDS = 120

const foo = new sst.aws.Function("Foo", {
  handler: "pkgs/functions/src/foo/handler.handler",
  timeout: `${API_TIMEOUT_SECONDS} seconds`,
  url: {
    cors: API_CORS_CONFIG, // ℹ️ this gets ignored when using router.route
  }
})

// ℹ️ add this config, with the `readTimeout` set, which works
router.route("/foo", foo.url, {
  readTimeout: `${API_TIMEOUT_SECONDS} seconds`, 
})

the issue is, when i do this, the cors config is completely ignored and i just get cors errors.

trying to configure the lambda like this, with the router config embedded does not expose any override on the cloudfront timeout:

const API_TIMEOUT_SECONDS = 120

const foo = new sst.aws.Function("Foo", {
  handler: "pkgs/functions/src/foo/handler.handler",
  timeout: `${API_TIMEOUT_SECONDS} seconds`,
  url: {
    router: {
      instance: router,
      path: "/foo",
      // ℹ️ can't override readTimeout
    },
    cors: API_CORS_CONFIG,
  }
})