File tree Expand file tree Collapse file tree
src/main/java/xyz/gianlu/librespot/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656 <artifactId >undertow-core</artifactId >
5757 <version >2.0.27.Final</version >
5858 </dependency >
59+ <dependency >
60+ <groupId >com.stijndewitt.undertow.cors</groupId >
61+ <artifactId >undertow-cors-filter</artifactId >
62+ <version >0.4.0</version >
63+ </dependency >
5964 </dependencies >
6065</project >
Original file line number Diff line number Diff line change 11package xyz .gianlu .librespot .api ;
22
3+ import com .stijndewitt .undertow .cors .AllowAll ;
4+ import com .stijndewitt .undertow .cors .Filter ;
35import io .undertow .Undertow ;
46import io .undertow .server .RoutingHandler ;
57import org .apache .log4j .Logger ;
@@ -32,7 +34,12 @@ public void start(@NotNull Session session) {
3234 RoutingHandler handler = new RoutingHandler ();
3335 prepareHandlers (handler , session );
3436
35- undertow = Undertow .builder ().addHttpListener (port , "" , handler ).build ();
37+ Filter corsFilter = new Filter (handler );
38+ corsFilter .setPolicyClass (AllowAll .class .getCanonicalName ());
39+ corsFilter .setPolicyParam (null );
40+ corsFilter .setUrlPattern (".*" );
41+
42+ undertow = Undertow .builder ().addHttpListener (port , "" , corsFilter ).build ();
3643 undertow .start ();
3744 LOGGER .info (String .format ("Server started on port %d!" , port ));
3845 }
You can’t perform that action at this time.
0 commit comments