Skip to content

Commit

Permalink
response charset
Browse files Browse the repository at this point in the history
  • Loading branch information
crizzzly committed Jan 6, 2025
1 parent f52b25a commit f4756be
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.affenbande.affenbandeBackend.config

import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.filter.CharacterEncodingFilter
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

Expand Down Expand Up @@ -33,6 +35,16 @@ class WebConfig {
}
}
}

@Bean
fun characterEncodingFilter(): FilterRegistrationBean<CharacterEncodingFilter?> {
val registrationBean: FilterRegistrationBean<CharacterEncodingFilter?> = FilterRegistrationBean<CharacterEncodingFilter?>()
registrationBean.filter = CharacterEncodingFilter()
registrationBean.addUrlPatterns("/*") // Or specific patterns
registrationBean.addInitParameter("encoding", "UTF-8")
registrationBean.addInitParameter("forceEncoding", "true") // Important for setting response charset
return registrationBean
}
}

// TODO: add restrictions to admin page - only allowed users

0 comments on commit f4756be

Please sign in to comment.