Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跨域问题怎么解决呢大佬 #10

Open
TangStudio opened this issue Aug 12, 2022 · 1 comment
Open

跨域问题怎么解决呢大佬 #10

TangStudio opened this issue Aug 12, 2022 · 1 comment

Comments

@TangStudio
Copy link

如题

@zzy-33
Copy link

zzy-33 commented Jan 3, 2023

如题

androidServer
    .filter("/*", object : HttpFilter {
        override fun before(request: Request): Boolean {
            return true
        }

        override fun after(request: Request, response: Response) {
            response.addHeader(HttpHeaderNames.CONTENT_TYPE, "application/json;charset=UTF-8")
            response.addHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN, "*")
            response.addHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS, "*")
            response.addHeader(
                HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS,
                "GET, POST, PUT,DELETE"
            )
            response.addHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")
            Log.d("HttpService", "after....")
        }

    })
    .start()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants