@@ -854,37 +854,40 @@ func fromProjectConfiguration(projectConfig *ProjectConfiguration, localConfig *
854
854
})
855
855
}
856
856
857
- // check for duplicate paths in websites and error
858
- siteDuplicates := lo .FindDuplicatesBy (websites , func (website Website ) string {
859
- return website .path
860
- })
861
-
862
- // check that there is a root website
863
- _ , found := lo .Find (websites , func (website Website ) bool {
864
- return website .path == "/"
865
- })
866
- if ! found {
867
- return nil , fmt .Errorf ("no root website found, please add a website with path /" )
868
- }
869
-
870
- // ensure there /api path is not used
871
- _ , found = lo .Find (websites , func (website Website ) bool {
872
- return strings .TrimSuffix (website .path , "/" ) == "/api"
873
- })
874
- if found {
875
- return nil , fmt .Errorf ("path /api is reserved for API rewrites to APIs, please use a different path" )
876
- }
857
+ // website validation
858
+ if len (websites ) > 0 {
859
+ if ! slices .Contains (projectConfig .Preview , preview .Feature_Websites ) {
860
+ return nil , fmt .Errorf ("project contains websites, but the project does not have the 'websites' preview feature enabled. Please add websites to the preview field of your nitric.yaml file to enable this feature" )
861
+ }
877
862
878
- if len ( siteDuplicates ) > 0 {
879
- duplicatePaths := lo .Map ( siteDuplicates , func (website Website , i int ) string {
863
+ // check for duplicate paths in websites and error
864
+ siteDuplicates := lo .FindDuplicatesBy ( websites , func (website Website ) string {
880
865
return website .path
881
866
})
882
867
883
- return nil , fmt .Errorf ("duplicate website paths found: %s" , strings .Join (duplicatePaths , ", " ))
884
- }
868
+ if len (siteDuplicates ) > 0 {
869
+ duplicatePaths := lo .Map (siteDuplicates , func (website Website , i int ) string {
870
+ return website .path
871
+ })
885
872
886
- if len (websites ) > 0 && ! slices .Contains (projectConfig .Preview , preview .Feature_Websites ) {
887
- return nil , fmt .Errorf ("project contains websites, but the project does not have the 'websites' preview feature enabled. Please add websites to the preview field of your nitric.yaml file to enable this feature" )
873
+ return nil , fmt .Errorf ("duplicate website paths found: %s" , strings .Join (duplicatePaths , ", " ))
874
+ }
875
+
876
+ // check that there is a root website
877
+ _ , found := lo .Find (websites , func (website Website ) bool {
878
+ return website .path == "/"
879
+ })
880
+ if ! found {
881
+ return nil , fmt .Errorf ("no root website found, please add a website with path /" )
882
+ }
883
+
884
+ // ensure there /api path is not used
885
+ _ , found = lo .Find (websites , func (website Website ) bool {
886
+ return strings .TrimSuffix (website .path , "/" ) == "/api"
887
+ })
888
+ if found {
889
+ return nil , fmt .Errorf ("path /api is reserved for API rewrites to APIs, please use a different path" )
890
+ }
888
891
}
889
892
890
893
// create an empty local configuration if none is provided
0 commit comments