Skip to content
5 changes: 3 additions & 2 deletions app/eventyay/webapp/src/lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export function youtubeid(message) {
return helpers.withMessage(message, helpers.regex(/^[0-9A-Za-z_-]{5,}$/))
}
const relative = helpers.regex(/^\/.*$/)
const devurl = helpers.regex(/^http:\/\/localhost.*$/) // vuelidate does not allow localhost
// Allow localhost and local IP addresses (with or without port)
const localurl = helpers.regex(/^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:[0-9]+)?(\/.*)?$/)
export function url(message) {
return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || (ENV_DEVELOPMENT && devurl(value))))
return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || localurl(value)))
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the ENV_DEVELOPMENT check allows local URLs in production environments, which could expose internal development endpoints or testing URLs. Consider keeping the environment check or adding explicit configuration to control when local URLs are acceptable.

Suggested change
return helpers.withMessage(message, (value) => (!helpers.req(value) || _url(value) || relative(value) || localurl(value)))
return helpers.withMessage(message, (value) => (
!helpers.req(value) ||
_url(value) ||
relative(value) ||
(typeof ENV_DEVELOPMENT !== 'undefined' && ENV_DEVELOPMENT === true && localurl(value))
))

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ENV_DEVELOPMENT check expects the webapp to run in dev mode with a hot-reload server, but npm start under the webapp doesn’t work in our setup. So it was blocking valid localhost use.
Also here I am considering that we need localhost support in production for self-hosted and Docker setups.

}
export function isJson() {
return helpers.withMessage(({ $response }) => $response?.message, value => {
Expand Down