authentication – Intercept 200 response codes with nginx

I know that with nginx i can intercept any proxied response codes higher than 300 with:

proxy_intercept_errors on;
error_page 404 =200 /;

I would like to do the same thing, but for any response code, specially 200 and make it a 302, but can’t find any.

My use case is that i’m proxying to an API server that returns 200 for cases where access should be denied and 404 when access should be granted. When used along with nginx auth_request i’m having the opposite behavior so i need to make 404 =200 (so access will be granted, and this can already be done) and 200 =403 (so access will be denied, and this is where i can’t figure it out) to comply with auth_request.

How do I avoid caching a redirect response from a form?

I have a Drupal 8 form used by authenticated users which sometimes needs to redirect based on the presence of absence of something in session. I don’t want the redirect to be cached.

My form is displayed directly with a route. i.e., the route has a _form default pointing to the form class.

My buildForm method starts like this:

public function buildForm(array $form, FormStateInterface $form_state) 
    $form('#cache') = ('max-age' => 0);

    if (some value not in session) {
        $response = new TrustedRedirectResponse($some_url);
        throw new EnforcedResponseException($response);  

    // build the form.

I have not been able to avoid the redirect response being cached. It redirects as expected if the session variable does not exist but continues to redirect next time when the session variable does exist.

Users are authenticated so it is the dynamic page cache. drush cr or uninstalling the dynamic page cache “fixes” the problem.

Deny access to a path (give 403 or 404 response)

I know this should be easy. BBpress creates user profiles at /forums/users/.

I’d like to make them unavailable to anyone, and not be indexed by Google. I’ve tried the following (in .htaccess) and more, but nothing seems to work. Is it because these are not real directories, just a page hierarchy created by BBpress? What’s the solution?

# RedirectMatch 404 ^/fora/users/.*$

# RedirectMatch 404 ^.*/users/.*$

# this give internal server error throughout site:
# <Files ~ "/users/">
# Header set X-Robots-Tag "noindex, nofollow"
# </FilesMatch>

# RewriteEngine on
# RewriteRule ^.*/users/.*$ - (F)

8 – Creating a route that returns an AJAX Response that opens a modal

‚ÄčI have this route that is suppose to render a block and two view blocks and then display them in a modal.

Originally, I had this route created in the Pages section of Structure, but then decided to create it in my module using this tutorial

However, when I construct it in my module, now it won’t open in a modal. It attempts to, but then just fails with no errors in the console or in Drupal, so I can’t debug the issue because I can’t even find out what the issue is… If I go to the route directly in the browser instead of through a link, it just prints out an array of command objects

Here’s my code:

  path: "/user/results"
    _title: "My Results"
    _controller: 'Drupalmy_moduleControllerme3Controller::myResults'
    _user_is_logged_in: "TRUE"
    _is_ajax_request: 'TRUE'


class myController extends ControllerBase {
  function myResults() {
    $renderer = Drupal::service('renderer');

    $top_careers_view = views_embed_view('top_careers', 'block_top_careers');
    $top_careers = $renderer->render($top_careers_view);
    $matched_degrees_view = views_embed_view('matched_degrees', 'block_matched_degrees');
    $matched_degrees = $renderer->render($matched_degrees_view);

    $content = $top_careers . $matched_degrees;

    $title = "Title";
    $options = (
      'dialogClass' => 'my_modal'
    $response = new AjaxResponse();
    $response->addCommand(new OpenModalDialogCommand($title, $content, $options));

    return $response;


    "dialogClass": "my-modal"
  href="/{{ language }}/my/results">{{ 'Match More Careers'|t }}

At one point I had /my/results_test created in Pages that I would open up in a modal via the html link:

  class="ytp-magenta-button use-ajax"
    "dialogClass": "ytp-dashboard-me3-modal"
  href="/{{ language }}/my/results_test">{{ 'Match More Careers'|t }}

I also had the /my/results route still created in my module and if I created a modal-link (defined above) to it from one of the blocks in /my/result_test, then the /my/results route would open in a modal as expected.

So essentially, with what I have, I can open my modal route from another modal, but I can’t open it directly from a regular page…

plugins – Cache WP remote_get HTTP Response using Transients

Using wp_remote_get keeps pinging the API on every page load. Which increase the server resource.

Is it possible to cache the response of the API store it using Transients and use it for next 5 minutes instead of keep pinging everytime?

And After 5 Minutes it should send request again and rewrite the stored value.

Here is my code for API Request. How to do this? I’m new to this. Help me please

function display_api_response() {
    $api_url = "";
$response = wp_remote_get($api_url);
   if ( 200 === wp_remote_retrieve_response_code($response) ) {
        $body = wp_remote_retrieve_body($response);

        if ( 'a' === $body ) {
          echo 'A wins';
        }else {
          // Do something else.
add_action( 'init', 'display_api_response' );

rest api – WordPress custom endpoint returning blank response

I have written some custom endpoints in wordpress plugin. Previously when i used wp_send_json to return data from custom endpoint. But as of wordpress 5.5 the usage of wp_send_json is deprecated. Now Iam returning WP_REST_Response from the custom endpoint. But when i try the request after this logic change Iam getting blank responses.

Here is the code iam using to send response from callback.

public static function sendJSON($data)
        $response             = ();
        $response = ("result" => $data('data'), "result_length" => sizeof($data('data')), "status_message" => "Success", "status" => $data('status'));
        return new WP_REST_Response($response, 200);

physics engine – Collision response using the Minimum Translation Vector

I am trying to use the Minimum Translation Vector (MTV) returned from the SAT algorithm for simple collision response. Please see the example below.

enter image description here

By separating the colliding boxes by moving the black box along the MTV, the box is now colliding with the other green box below. Moving the black box along the MTV for the collision with this new box then brings the box back to colliding with the first box, and an infinite cycle of trying to separate the boxes begins.

Am I missing something, or is collision response not possible using the MTV?

apache 2.4 – mod_security 403 forbidden response is returning homepage content with WordPress mod_rewrite

I’m using mod_security on various websites, some WordPress and some not.

I notice that on a non WordPress website the following:

returns a 403 forbidden error code, along with the Apache “forbidden” error page. The mod_security error is written to the log.

However, on a WordPress install, bizzarely, the following:

returns a 403 forbidden error code and writes the error to the log, however it dispays the contents of the homepage, rather than the Apache “forbidden” error page.

I note that it behaves correctly on any other page, other than the homepage:

The above works as expected, and returns the Apache error page.

I can only assume this is some conflict with WordPress’s mod_rewrite rule which is as follows:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Is there something I’m missing here? I don’t want to display the homepage content when a mod_security rule is matched via the homepage.

json – Response Serialization error, how to fix it?

I am trying to decode a json data, but it throws an error:

() nw_protocol_get_quic_image_block_invoke dlopen libquic failed responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.decodingFailed(error: Swift.DecodingError.typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: (), debugDescription: "Expected to decode Dictionary<String, Any> but found an array instead.", underlyingError: nil))))

I think, I did it in a correct way, I checked for the type mismatch also, looks correct, but could not comprehend why am i still getting the error. .

here is my struct data:

 import Foundation

 struct Response<T: Codable>: Codable {
     var data: (T)?

 struct MyData: Codable {
     var id: Int
     var name: String
     var type: String
     var quantity: Int

and my serverCommunicator func:

static func getData() -> Promise<Response<MyData>> {
    let decoder = JSONDecoder()
    return Promise { seal in
        AF.request(API.getData, method: .get, parameters: .none).responseDecodable(of: Response<MyData>.self, decoder: decoder) { response in
            switch response.result {
                case .success(let val):
                    return seal.fulfill(val)
                case .failure(let err):
                    return seal.reject(err)

and my apiCall func inside VC didload:

func getData() {
    ServerCommunicator.getData().done  { response -> Void in
        guard != nil, let data = else {
            print("Data could not be obtained.. .")
        } = data
    }.catch { (err) in

NOTE: No api headers or parametrs exist in my api//

bitcoind – Bitcoin “scantxoutset” rpc command return response too slow

For one of our decentralized mobile wallet, We need to fetch balance of imported BTC address quickly.

After lot of research on google then I found Bitcoin deamon rpc command “scantxoutset”, which give unspent outputs of imported address.

The only problem with this command is that it takes more than a minute to return the response, which is too slow. User will not wait for 1 minute.

Anyone, could you please suggest me, is there any alternative to fetch the balance of imported BTC address quickly from the BTC node. ( not from any third party api)