diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..8fdd954df --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 \ No newline at end of file diff --git a/package.json b/package.json index 53bf036ef..e5c16b7a1 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "description": "", "license": "MIT", "dependencies": { - "serverlesswp": "^0.1.2" + "serverlesswp": "^0.2.0" }, "engines": { - "node": "18.x" + "node": "22.x" } } diff --git a/serverless.yml b/serverless.yml index 086c49082..67d5972d0 100644 --- a/serverless.yml +++ b/serverless.yml @@ -2,7 +2,7 @@ service: serverlesswp-wordpress-starter provider: name: aws - runtime: nodejs18.x + runtime: nodejs22.x httpApi: payload: '2.0' diff --git a/test/Dockerfile b/test/Dockerfile index 005799a26..5233315fc 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -1,4 +1,4 @@ -FROM public.ecr.aws/lambda/nodejs:18 +FROM public.ecr.aws/lambda/nodejs:22 COPY package.json ${LAMBDA_TASK_ROOT}/ RUN npm install --omit=optional --omit=dev @@ -12,6 +12,4 @@ COPY test/installer.php ${LAMBDA_TASK_ROOT}/wp/ RUN sed -i 's#{SQLITE_IMPLEMENTATION_FOLDER_PATH}#/tmp/wp/wp-content/plugins/sqlite-database-integration#' ${LAMBDA_TASK_ROOT}/wp/wp-content/db.php -RUN echo "define('FQDBDIR', '/tmp/db' );" >> ${LAMBDA_TASK_ROOT}/wp/wp-config.php - CMD [ "api/index.handler" ] \ No newline at end of file diff --git a/test/run.sh b/test/run.sh index 85edd5ffb..077a2c35e 100755 --- a/test/run.sh +++ b/test/run.sh @@ -2,11 +2,12 @@ ./build-test.sh -docker run -p 9000:8080 -d -e FQDBDIR='/tmp/db' --name serverlesswp-test serverlesswp-test +docker run -e FQDBDIR=/tmp/db -p 9000:8080 -d --name serverlesswp-test serverlesswp-test -curl -s -o /dev/null -w "%{http_code}" -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/installer.php"}' +curl -s -o /dev/null -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/installer.php"}' + +curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/"}' -curl -s -o /dev/null -w "%{http_code}" -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/"}' docker stop serverlesswp-test docker rm serverlesswp-test \ No newline at end of file diff --git a/vercel.json b/vercel.json index 7f5110716..dce08dd4c 100644 --- a/vercel.json +++ b/vercel.json @@ -4,8 +4,8 @@ ], "functions": { "api/index.js": { - "memory": 1024, - "includeFiles": "wp/**" + "includeFiles": "wp/**", + "maxDuration": 60 } }, "build": { diff --git a/wp/wp-config.php b/wp/wp-config.php index 22eaed7b9..598422b84 100644 --- a/wp/wp-config.php +++ b/wp/wp-config.php @@ -91,9 +91,18 @@ /* Add any custom values between this line and the "stop editing" line. */ -define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL ); +if (!isset($_ENV['SKIP_MYSQL_SSL'])) { + define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL ); +} + $_SERVER['HTTPS'] = 'on'; +// Inject the true host. +$headers = getallheaders(); +if (isset($headers['injectHost'])) { + $_SERVER['HTTP_HOST'] = $headers['injectHost']; +} + // Optional S3 credentials for file storage. if (isset($_ENV['S3_KEY_ID']) && isset($_ENV['S3_ACCESS_KEY'])) { define( 'AS3CF_SETTINGS', serialize( array(