-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from danthe1st/cors-fix
- Loading branch information
Showing
2 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/net/discordjug/javabot/api/routes/CorsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.discordjug.javabot.api.routes; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.FilterChain; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.filter.OncePerRequestFilter; | ||
|
||
/** | ||
* This filter enables CORS for all endpoints. | ||
*/ | ||
@Component | ||
public class CorsFilter extends OncePerRequestFilter { | ||
|
||
@Override | ||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) | ||
throws ServletException, IOException { | ||
response.addHeader("Access-Control-Allow-Origin", "*"); | ||
response.addHeader("Access-Control-Allow-Methods", "POST, PUT, DELETE, GET, OPTIONS"); | ||
filterChain.doFilter(request, response); | ||
} | ||
|
||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/net/discordjug/javabot/api/routes/WebConfigurer.java
This file was deleted.
Oops, something went wrong.