diff --git a/src/app.ts b/src/app.ts index d5b5d110..61380dad 100644 --- a/src/app.ts +++ b/src/app.ts @@ -21,7 +21,7 @@ import { UserInfo } from './controllers/user_info.js' import path from 'path' const swagger_options = { - customJs: './custom_button.js', + customJs: '/static/custom_button.js', } dotenv.config() @@ -56,7 +56,6 @@ class App { this.express.use(handleAuthRoutes(configLogToExpress)) this.express.use(withLogto(configLogToExpress)) this.express.use(express.text()) - this.express.use(express.static(path.join(process.cwd(), '/src/static'))) this.express.use( '/swagger', @@ -96,6 +95,12 @@ class App { app.post(`/account`, new CustomerController().create) app.get(`/account`, new CustomerController().get) + // static files + app.get('/static/custom_button.js', + express.static( + path.join(process.cwd(), '/dist/src'), + {extensions: ['js'], index: false})) + // 404 for all other requests app.all('*', (req, res) => res.status(400).send('Bad request')) } diff --git a/src/middleware/authentication.ts b/src/middleware/authentication.ts index 2a3ea9df..4da966e1 100644 --- a/src/middleware/authentication.ts +++ b/src/middleware/authentication.ts @@ -110,7 +110,7 @@ export class Authentication { response.locals.customerId = DEFAULT_CUSTOMER_ID } else { return response.status(400).json({ - error: `Unauthorized error. It requires ENABLE_AUTH=true and bearerToken in headers or CUSTOMER_ID to be set.` + error: `Unauthorized error. It requires ENABLE_AUTHENTICATION=true and bearerToken in headers or DEFAULT_CUSTOMER_ID to be set.` }) } next() diff --git a/src/types/types.ts b/src/types/types.ts index 231b0de0..4d5f983c 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -114,7 +114,7 @@ class MethodToScope { export class ApiGuarding { private routeToScoupe: MethodToScope[] = [] - private static pathSkip = ['/', '/swagger', '/user'] + private static pathSkip = ['/', '/swagger', '/user', '/static/custom_button.js'] private static regExpSkip = new RegExp("^/.*js") constructor() { this.registerRoute('/account', 'GET', 'account:read')