Comments (6)
this sounds like you have the filter ordering incorrect
from micronaut-core.
@graemerocher thanks for quick reply. Is Cors filter of highest precedence?
As per cors filter code in Micronaut. I believe it is returning a response decorated with preflight headers if status is < 400.
In this case, how can I specify cors filter to be of highest precedence?
@NonNull
private Publisher<MutableHttpResponse<?>> handlePreflightRequest(@NonNull HttpRequest<?> request, @NonNull ServerFilterChain chain, @NonNull CorsOriginConfiguration corsOriginConfiguration) {
Optional<HttpStatus> statusOptional = this.validatePreflightRequest(request, corsOriginConfiguration);
if (statusOptional.isPresent()) {
HttpStatus status = (HttpStatus)statusOptional.get();
if (status.getCode() >= 400) {
return Publishers.just(HttpResponse.status(status));
} else {
MutableHttpResponse<?> resp = HttpResponse.status(status);
this.decorateResponseWithHeadersForPreflightRequest(request, resp, corsOriginConfiguration);
this.decorateResponseWithHeaders(request, resp, corsOriginConfiguration);
return Publishers.just(resp);
}
} else {
return Publishers.then(chain.proceed(request), (respx) -> {
this.decorateResponseWithHeadersForPreflightRequest(request, respx, corsOriginConfiguration);
this.decorateResponseWithHeaders(request, respx, corsOriginConfiguration);
});
}
}
Can cors filter ever proceed with chain request if options preflight request succeeded and land into custom authorization filter and still fail there?
from micronaut-core.
@graemerocher can you please suggest how can I fix the ordering so that cors filter runs first?
from micronaut-core.
Add an order to your own filter that is higher than that of the cors filter, which should be 9250
from micronaut-core.
@yawkat
Few findings:
On using
@order(Ordered.LOWEST_PRECEDENCE) on the custom filter, its not working.
It fails on OPTIONS request.
curl --location --request OPTIONS 'http://localhost:8080/v2/api' \
--header 'Origin: http://www.google.com' \
--header 'Access-Control-Request-Method: POST'
But overriding the method getOrder works
override fun getOrder(): Int {
return Integer.MAX_VALUE
}
from micronaut-core.
Hey any updates here?
from micronaut-core.
Related Issues (20)
- Code generated with `@Around` does not retain (?) visibility modifier of original class
- Action Required: Fix Renovate Configuration
- Micronaut not picking up spring @RestController apis defined in 3rd party spring boot jar
- Graal annotation processor doesn't mark package-private injected fields for reflective access HOT 1
- Multiple client filters in Micronaut HOT 8
- Connection closed before response was received on concurrent requests HOT 1
- Micronaut v4.3.1 causing stackoverflow exception on java compilation HOT 3
- @RequestScope cannot be used with HTTP client blocking requests HOT 7
- Instantiation methods in introspection of abstract class tries to instantiate the abstract class
- NoSuchMethodError/KSP generated bean definition constructor missing parameters for class with AOP advice HOT 2
- Non-nullable Long Kotlin data class field initialized with 0 when field is missing in payload
- While upgrading to micronuat 4.4 from 3.8 HTTPResponse Body content is in unpooledContent and body is null HOT 6
- Rendering issue in docs
- Injection of map of beans does not work if some of the services are injected by implementation type HOT 1
- Micronaut Management stopped working after migration to Micronaut 4.5.3 HOT 4
- Micronaut 3 to 4 migration issue: request.getHaaders.getFirst (key, type.class) can no longer convert HOT 1
- CompletableFuture endpoint with a redirect response returns a 200
- Micronaut 4 throws 404 error for an endpoint having special characters in path parameter
- SslContext with Micronaut HttpClient HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micronaut-core.