You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The handler in .output/server/index.js produced when using
npm run build -- --preset aws_lambda
from a new SolidStart project is able to handle the initial request and provide the initial rendered HTML, but fails to return the remaining requested assets (JavaScript chunks and CSS). Responses coming back for the remaining requested assets are all 404 page HTML renderings, instead of the expected filetype (JavaScript or CSS). The JavaScript files all have responses like this:
The status code for these responses is 200, not 404.
Expected behavior 🤔
The bundle produced serves an identical rendered page to the local rendering seen when using npm run dev. The CSS contents are CSS, the JavaScript contents are JavaScript, and the status codes for the responses are 200.
If the 404 page is rendered, I'd like to see a 404 status code in the response, not a 200.
Steps to reproduce 🕹
Steps:
Create a new SolidStart project:
npm init solid@latest
I chose "with-tailwindcss" but I don't think it matters.
Build the SolidStart bundle targeting AWS Lambda deployment:
import*ascdkfrom"aws-cdk-lib";import{Construct}from"constructs";import*asapigwfrom"aws-cdk-lib/aws-apigatewayv2";import*aslambdafrom"aws-cdk-lib/aws-lambda";import*asintegrationsfrom"aws-cdk-lib/aws-apigatewayv2-integrations";exportclassSolidStartStackextendscdk.Stack{constructor(scope: Construct,id: string,props?: cdk.StackProps){super(scope,id,props);constbackendLambda=newlambda.Function(this,"SolidBackendLambda",{runtime: lambda.Runtime.NODEJS_20_X,handler: "index.handler",code: lambda.Code.fromAsset("./.output/server"),architecture: lambda.Architecture.ARM_64,});constapi=newapigw.HttpApi(this,"Endpoint",{defaultIntegration: newintegrations.HttpLambdaIntegration("SolidIntegration",backendLambda,),});newcdk.CfnOutput(this,"HTTP API URL",{value: api.url??"Something went wrong with the deploy",});}}
Add the CDK app to cdk/bin/cdk.ts:
#!/usr/bin/env node
import"source-map-support/register";import*ascdkfrom"aws-cdk-lib";import{SolidStartStack}from"../lib/solid-stack";constapp=newcdk.App();newSolidStartStack(app,"SolidStartApp",{/* If you don't specify 'env', this stack will be environment-agnostic. * Account/Region-dependent features and context lookups will not work, * but a single synthesized template can be deployed anywhere. *//* Uncomment the next line to specialize this stack for the AWS Account * and Region that are implied by the current CLI configuration. */env: {account: process.env.CDK_DEFAULT_ACCOUNT,region: process.env.CDK_DEFAULT_REGION,},/* Uncomment the next line if you know exactly what Account and Region you * want to deploy the stack to. */// env: { account: '123456789012', region: 'us-east-1' },/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */});
where the HTTPAPIURL should be a valid URL that you can hit to see your SolidStart app.
Open the URL in your browser and you should see a basic HTML page with the counter button and with no styling. Inspecting the network calls, you should see that the responses for the CSS and JS files are HTML with the rendered 404 page, but with status code 200.
Context 🔦
I'm trying to deploy a SSR SolidStart site with AWS Lambda as the deployment target. I expect the Lambda to serve the dynamic content as well as the static assets by default.
Later I would like to gather the static client assets and deploy them to CloudFront, letting CloudFront serve the static content and the Lambda instance serving the dynamic portion, but right now, I'm just trying to prove out I can get a deployment target of AWS Lambda to work.
I was attracted to SolidStart as a framework because, after a bit of digging, I realized that users seemed to be able to leverage all the deployment providers available in Nitro.
It's possible this functionality is entirely Vinxi's responsibility and it never worked for any meta-metaframework built on it—not only SolidStart—however, I'm starting here with SolidStart because that's what I'm intending to use, and I'm not yet familiar with this Jenga tower of SolidStart→Vinxi→Nitro→Vite→Rollup (and anything else I missed). 😅
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered:
Though seeing as each static asset would require a function invocation, it might be better to put the assets in CloudFront for faster access. SST Ion's Solid Start component does this via Pulumi.
@Brendonovich what's your recommendation here? It sounds like this might be by design? It doesn't sound like Start could do much here. Is there something that could be submitted against Nitro?
Yeah I'd say this is by design. If Nitro were to do anything i think they should mention in the lambda preset docs that the files in .output/public need to be hosted somewhere else under the same domain, usually CloudFront. I don't think there's anything Start can/should do here.
Thank you, @Brendonovich, for the helpful reply. I am in agreement. I was interested in a single-service (i.e., Lambda-only) deployment of the build from the perspective of simplicity, but it's not a good setup for production. It is an anti-pattern given that Lambda is pay-by-use and you're wasting CPU time funneling static assets through it.
It turns out not much more difficult to go ahead and set up CloudFront with the server-bundle Lambda as the default origin, and the static frontend bundle/assets from an S3 origin. I think that is the sane default, to push users into "the pit of success".
Duplicates
Latest version
Current behavior 😯
The
handler
in.output/server/index.js
produced when usingfrom a new SolidStart project is able to handle the initial request and provide the initial rendered HTML, but fails to return the remaining requested assets (JavaScript chunks and CSS). Responses coming back for the remaining requested assets are all 404 page HTML renderings, instead of the expected filetype (JavaScript or CSS). The JavaScript files all have responses like this:
The status code for these responses is 200, not 404.
Expected behavior 🤔
The bundle produced serves an identical rendered page to the local rendering seen when using
npm run dev
. The CSS contents are CSS, the JavaScript contents are JavaScript, and the status codes for the responses are 200.If the 404 page is rendered, I'd like to see a 404 status code in the response, not a 200.
Steps to reproduce 🕹
Steps:
Create a new SolidStart project:
I chose "with-tailwindcss" but I don't think it matters.
Build the SolidStart bundle targeting AWS Lambda deployment:
Install the CDK dependencies:
Create the CDK directories:
Add the CDK stack to
cdk/lib/solid-stack.ts
:Add the CDK app to
cdk/bin/cdk.ts
:Add the
cdk.json
file:Export your CDK environment variables:
Ensure AWS CLI credentials are set up; for me this looks like:
Deploy the CDK stack:
The deployment should succeed, and you should see an output like:
where the
HTTPAPIURL
should be a valid URL that you can hit to see your SolidStart app.Open the URL in your browser and you should see a basic HTML page with the counter button and with no styling. Inspecting the network calls, you should see that the responses for the CSS and JS files are HTML with the rendered 404 page, but with status code 200.
Context 🔦
I'm trying to deploy a SSR SolidStart site with AWS Lambda as the deployment target. I expect the Lambda to serve the dynamic content as well as the static assets by default.
Later I would like to gather the static client assets and deploy them to CloudFront, letting CloudFront serve the static content and the Lambda instance serving the dynamic portion, but right now, I'm just trying to prove out I can get a deployment target of AWS Lambda to work.
I was attracted to SolidStart as a framework because, after a bit of digging, I realized that users seemed to be able to leverage all the deployment providers available in Nitro.
It's possible this functionality is entirely Vinxi's responsibility and it never worked for any meta-metaframework built on it—not only SolidStart—however, I'm starting here with SolidStart because that's what I'm intending to use, and I'm not yet familiar with this Jenga tower of SolidStart→Vinxi→Nitro→Vite→Rollup (and anything else I missed). 😅
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: