Skip to content

Commit

Permalink
feat: allow configuring api prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Nov 6, 2023
1 parent e1ec543 commit 5a52304
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| HASURA_GRAPHQL_ADMIN_SECRET<b>\*</b> | Hasura GraphQL Admin Secret. Required to manipulate account data. | |
| AUTH_HOST | Server host. This option is available until Hasura-auth `v0.6.0`. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `0.0.0.0` |
| AUTH_PORT | Server port. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `4000` |
| AUTH_API_PREFIX | API prefix | `/` |
| AUTH_SERVER_URL | Server URL of where Hasura Backend Plus is running. This value is to used as a callback in email templates and for the OAuth authentication process. | |
| AUTH_CLIENT_URL | URL of your frontend application. Used to redirect users to the right page once actions based on emails or OAuth succeed. | |
| AUTH_CONCEAL_ERRORS | Conceal sensitive error messages to avoid leaking information about user accounts to attackers | `false` |
Expand Down
4 changes: 3 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { httpLogger, logger, uncaughtErrorLogger } from './logger';
import { authMiddleware } from './middleware/auth';
import { addOpenApiRoute } from './openapi';
import router from './routes';
import { ENV } from './utils/env';


const app = express();

Expand All @@ -19,7 +21,7 @@ addOpenApiRoute(app);
app.use(httpLogger);
app.use(helmet(), json(), cors());
app.use(authMiddleware);
app.use(router);
app.use(ENV.AUTH_API_PREFIX, router);
app.use(uncaughtErrorLogger, serverErrors);

process.on('unhandledRejection', (reason) => {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const ENV = {
get AUTH_SERVER_URL() {
return castStringEnv('AUTH_SERVER_URL');
},
get AUTH_API_PREFIX() {
return castStringEnv('AUTH_API_PREFIX', '/');
},

// SMTP
get AUTH_SMTP_PASS() {
Expand Down

0 comments on commit 5a52304

Please sign in to comment.