2 Replies Latest reply on Aug 25, 2020 5:39 PM by Rumburak 9000

    X-APEX-FORWARD/X-ORDS-FORWARD: URL is not permitted because it lies outside the context path of

    Rumburak 9000

      Hello,

       

      i wanted to redirect from an ords-POST-Request to another URL by setting the X-ORDS-FORWARD-Variable but I got an http-500:

       

      SEVERE: Handler for: POST /ords/bla/blupp/import/test1 attempted to forward request to: http://server1/blabla which is not permitted because it lies outside the context path of: http://server1/ords/bla/

      Aug 25, 2020 3:08:20 PM

      SEVERE: null

      InternalServerException [statusCode=500, reasons=[]]

              at oracle.dbtools.http.forwarding.ForwardingFilter.doFilter(ForwardingFilter.java:137)

              at oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:47)

       

      Is the redirect only possible for urls in the ords-context?

       

      Bye,

       

      Rumburak

        • 1. Re: X-APEX-FORWARD/X-ORDS-FORWARD: URL is not permitted because it lies outside the context path of
          EJ-Egyed

          I believe that if you are using the :forward_location implicit bind parameter to try to forward the request, it does need to be within the ORDS context.  More information about that parameter can be found here: https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/19.2/aelig/implicit-parameters.html#GUID-A3026B27-3…

           

          If you do wish to redirect the user of the endpoint, you could try forwarding the request along using a redirect.  I have created an example that will return the root page of the server which you can modify to add /blabla to the end of the redirect.  When testing the endpoint from Postman, I am presented with the homepage of my server but without any CSS/Javascript.  I am using ORDS 19.2.

           

          BEGIN
              ORDS.ENABLE_SCHEMA (p_enabled               => TRUE,
                                  p_url_mapping_type      => 'BASE_PATH',
                                  p_url_mapping_pattern   => 'api-test',
                                  p_auto_rest_auth        => FALSE);
          
              ORDS.DEFINE_MODULE (p_module_name => 'v1', p_base_path => '/v1/');
          
              ORDS.DEFINE_TEMPLATE (p_module_name => 'v1', p_pattern => 'demo');
          
              ORDS.DEFINE_HANDLER (
                  p_module_name   => 'v1',
                  p_pattern       => 'demo',
                  p_method        => 'POST',
                  p_source_type   => 'plsql/block',
                  p_source        =>
                      'begin
                        :redirect_to := OWA_UTIL.get_cgi_env(''REQUEST_PROTOCOL'') || ''://'' || OWA_UTIL.get_cgi_env(''HTTP_HOST'');
                        :status_code := 302;
                      end;');
          
              ORDS.DEFINE_PARAMETER (p_module_name          => 'v1',
                                     p_pattern              => 'demo',
                                     p_method               => 'POST',
                                     p_name                 => 'Location',
                                     p_bind_variable_name   => 'redirect_to',
                                     p_source_type          => 'HEADER',
                                     p_param_type           => 'STRING',
                                     p_access_method        => 'OUT');
              COMMIT;
          END;
          
          1 person found this helpful