Ollie Camp
09/14/2021, 1:52 PMhttps://${Token[TOKEN.186]}
which then results in the following error error Cannot find a handler file for "https://${Token[TOKEN.186]}"
.
I'm sure I've missed something obvious but I've now been starring at this problem to long to see it!
lib/index.js
import MyStack from "./MyStack";
import AssetsStack from "./AssetsStack";
export default function main(app) {
// Set default runtime for all functions
app.setDefaultFunctionProps({
runtime: "nodejs14.x"
});
const assets = new AssetsStack(app, "assets-stack");
new MyStack(app, "my-stack", { asset_url: assets.url });
}
lib/AssetsStack.js
import { Stack, StaticSite } from "@serverless-stack/resources";
export default class AssetsStack extends Stack {
url
constructor(scope, id, props) {
super(scope, id, props);
// Create a Sattic Site
const assets = new StaticSite(this, "Assets", {
path: 'src/build/assets/'
})
this.url = assets.url
// Show the endpoint in the output
this.addOutputs({
"CloudFrontEndpoint": assets.url
});
}
}
lib/MyStack.js
import { Stack, Api } from "@serverless-stack/resources";
export default class MyStack extends Stack {
constructor(scope, id, props) {
super(scope, id, props);
const { asset_url } = props
// Create a HTTP API
const api = new Api(this, "Api", {
routes: {
"GET /_app": asset_url,
"$default": "src/lambda.handler",
},
});
// Show the endpoint in the output
this.addOutputs({
"ApiEndpoint": api.url
});
}
}
thdxr
09/14/2021, 1:53 PMthdxr
09/14/2021, 1:54 PM/_app
to the static site? If so you should be defining the route like this I believe
"GET /_app": { url: asset_url}
thdxr
09/14/2021, 1:55 PMOllie Camp
09/14/2021, 1:55 PMOllie Camp
09/14/2021, 1:57 PMOllie Camp
09/14/2021, 2:01 PM"GET /_app": { url: asset_url}
This solved it, it now works as I was expecting it! Did I miss this in the SST Api docs?thdxr
09/14/2021, 2:07 PMthdxr
09/14/2021, 2:07 PMOllie Camp
09/14/2021, 2:12 PMOllie Camp
09/14/2021, 2:13 PMthdxr
09/14/2021, 2:14 PMOllie Camp
09/14/2021, 2:15 PMOllie Camp
09/14/2021, 2:16 PMthdxr
09/14/2021, 2:18 PMOllie Camp
09/14/2021, 2:20 PMsst start
clears the s3 bucket after a deploy 🥲thdxr
09/14/2021, 2:21 PMsst deploy
. I did just make this ticket to disable it https://github.com/serverless-stack/serverless-stack/issues/817Ollie Camp
09/14/2021, 2:22 PMOllie Camp
09/14/2021, 2:23 PMOllie Camp
09/14/2021, 2:42 PMthdxr
09/14/2021, 2:58 PMOllie Camp
09/14/2021, 4:58 PMthdxr
09/14/2021, 4:58 PM