diff --git a/astro.config.mjs b/astro.config.mjs index 6e362ef..5e52d94 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,8 +1,12 @@ import { defineConfig } from "astro/config"; +import netlify from "@astrojs/netlify/functions"; + // https://astro.build/config export default defineConfig({ redirects: { "/branding": "/brand", }, + output: "server", + adapter: netlify(), }); diff --git a/bun.lockb b/bun.lockb index 4dd5dae..e86b90e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/netlify.toml b/netlify.toml index 2afbe24..74d4177 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,4 +8,4 @@ [[redirects]] from = "/api/*" to = "/.netlify/functions/:splat" - status = 200 \ No newline at end of file + status = 200 diff --git a/netlify/functions/fetch/fetch.js b/netlify/functions/fetch/fetch.js deleted file mode 100755 index b60689d..0000000 --- a/netlify/functions/fetch/fetch.js +++ /dev/null @@ -1,51 +0,0 @@ -// fetch.js -const axios = require("axios"); -const qs = require("qs"); // Add this line - -exports.handler = async function (event, context) { - try { - // Parse the incoming form data from the request body - const { name, email, gdpr, hp, list, subform, boolean } = JSON.parse( - event.body, - ); - - // Stringify the data into a query string - const data = qs.stringify({ - name, - email, - gdpr, - hp, - list, - subform, - boolean, - }); - - // Make the cURL request using axios - const response = await axios.post( - "https://postal.hackclub.com/subscribe", - data, - { - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - }, - ); - - // log the response for debugging purposes - console.log(response.data); - - // Return the response from the external API - return { - statusCode: response.status, - body: JSON.stringify(response.data), - }; - } catch (error) { - // Return an error response if something goes wrong - // log the error for debugging purposes - console.log(error); - return { - statusCode: 500, - body: JSON.stringify({ error: "Internal Server Error" }), - }; - } -}; diff --git a/package.json b/package.json index b4b97ef..6225c1f 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,11 @@ "version": "1.1.0", "private": true, "dependencies": { + "@astrojs/netlify": "^5.2.1", "astro": "^4.0.4", + "axios": "^1.6.2", "magick.css": "^1.0.5", "normalize.css": "^8.0.1", - "axios": "^1.6.2", "qs": "^6.12.0" }, "scripts": { diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 2d753e9..0e94c7a 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -29,7 +29,10 @@ const year = new Date().getFullYear(); - + @@ -24,11 +56,8 @@ import Layout from "../layouts/Layout.astro";

-
+ {error &&

Error: {error}

} +