Skip to content

Instantly share code, notes, and snippets.

@viktorfa
Last active August 16, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktorfa/23847bd9f9926872f860455329b0153e to your computer and use it in GitHub Desktop.
Save viktorfa/23847bd9f9926872f860455329b0153e to your computer and use it in GitHub Desktop.
Server config for Strapi in Serverless
// config/server.js
// This config is used both in `strapi build` and `strapi start`.
// So if we have a path prefix to the api, such as /dev or /v1,
// we need to use env variables to configure, as Strapi doesn't
// support path prefixes automagically.
module.exports = ({ env }) => {
let url = "<Insert Lambda endpoint url here after deploy.>";
// Check if running in serverless-offline
if (env("IS_OFFLINE", null) === "true") {
url = "http://localhost:3000/dev";
}
return {
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
url,
admin: {
serveAdminPanel: false, // No admin panel
autoOpen: false,
url: "/",
auth: {
secret: env("ADMIN_JWT_SECRET", "Insert random string as env variable in production"),
},
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment