When you start entering a new string into the URL field of a content type, it defaults to leading with a forwards slash. However, a content editor can remove this and still publish the content (ie “/about” vs “about”). The problem that I have found is that on a NextJS site using SSR the context.resolvedUrl object in getServerSideProps will always return a leading forwards slash. When we query the API with this value, it won’t grab any entries which have had the forwards slash removed by a content editor.
Outside of custom field validation, is there any way around this?
Best answer by bethany.wilesView original
Rather than building out a custom field, I’d go with a single line textbox field and use the advanced settings to configure a Regex validation that checks for the /. You can see more in the docs on that here: https://www.contentstack.com/docs/developers/create-content-types/validation-regex/. Should be quicker than building a custom field. Let me know if that works for you.