Resource access method and device
By generating cross-domain proxy requests and adding proxy identification parameters in the low-code development platform, the problem of high complexity and low efficiency of application access resources is solved, and the resource access method is realized that can effectively access different domain name interfaces without cross-domain resource sharing configuration.
Patent Information
- Application Number
- CN202111664836.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-04-16
- Filing Date
- 2021-12-31
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In low-code development platforms, applications have high complexity and low resource access efficiency, which leads to business applications not being able to effectively access interfaces of different domain names during debugging and previewing, and requires cross-domain resource sharing configuration.
By generating cross-domain proxy requests based on resource request messages sent by the target application and adding proxy identification parameters to cross-domain proxy requests, we ensure that the proxy server successfully receives cross-domain proxy requests and returns the correct resources to be accessed without cross-domain resource sharing configuration.
Reduces the complexity of resource access, improves resource access efficiency, and ensures the success and accuracy of resource access, allowing business applications to access interfaces of different domain names without cross-domain resource sharing configuration.
Smart Images

Figure CN115225707B_ABST
Abstract
Description
[0001] This application claims priority to the Chinese application filed on April 16, 2021, with application number 202110411765.4 and invention name “Resource access method, device, equipment and storage medium”, the entire contents of which are incorporated into this application by reference. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a resource access method and device. Background Art
[0003] Low-Code Development Platform (LCDP) is a development platform that can quickly generate applications without coding or with a small amount of code. Through a visual application development method, developers with different experience levels can create web and mobile applications through a graphical user interface, using drag-and-drop components and model-driven logic.
[0004] If you want to quickly preview the effects of a business application (the application being developed) in a low-code development platform, you need to render the current application in real time. At this time, the domain name to which the application belongs is the domain name of the low-code development platform. Business applications (developed applications) can only request interfaces with the same domain name as the low-code development platform website, and cannot request interfaces with other business domain names. If a business application requests an interface with its corresponding business domain name, cross-domain access will occur, and the business application request will be intercepted by the browser. If you want to request a business domain name interface, the business server of the interface provider needs to set up cross-origin resource sharing (CORS) configuration so that the business application can debug the interface and preview the effects.
[0005] In related technologies, application access to resources in low-code development platforms has high complexity and low resource access efficiency. Summary of the invention
[0006] The embodiments of the present application provide a resource access method and device, which reduce the complexity of resource access, improve resource access efficiency, and ensure the success rate and accuracy of resource access.
[0007] According to one aspect of an embodiment of the present application, a resource access method is provided, the method comprising:
[0008] Obtaining a resource request message sent by a target application, wherein the resource request message includes location information of a resource to be accessed;
[0009] If the message sending mode of the resource request message is a cross-domain proxy mode, a proxy identification parameter is generated; a cross-domain proxy request is generated according to the proxy identification parameter and the location information; and the cross-domain proxy request is sent to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache policy;
[0010] A response message sent by the proxy server is received, wherein the response message includes the resource to be accessed.
[0011] According to one aspect of an embodiment of the present application, a resource access method is provided, the method comprising:
[0012] receiving a cross-domain proxy request, wherein the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set;
[0013] Generate a resource acquisition request based on the location information of the resource to be accessed;
[0014] Sending the resource acquisition request to a resource server;
[0015] Receiving a response message sent by the resource server, wherein the response message includes the resource to be accessed;
[0016] Forward the response message to the terminal.
[0017] According to one aspect of an embodiment of the present application, a resource access device is provided, the device comprising:
[0018] A request acquisition module, used to acquire a resource request message sent by a target application, wherein the resource request message includes location information of a resource to be accessed;
[0019] An identification generating module, configured to generate an agent identification parameter if the message sending mode of the resource request message is a cross-domain agent mode;
[0020] A proxy request generation module, used to generate a cross-domain proxy request according to the proxy identification parameter and the location information;
[0021] A request sending module, used to send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache policy;
[0022] The message receiving module is used to receive a response message sent by the proxy server, wherein the response message includes the resource to be accessed.
[0023] According to one aspect of an embodiment of the present application, a resource access device is provided, the device comprising:
[0024] A request receiving module, used to receive a cross-domain proxy request, wherein the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set;
[0025] A resource request generation module, used to generate a resource acquisition request based on the location information of the resource to be accessed;
[0026] A resource request sending module, used for sending the resource acquisition request to a resource server;
[0027] A resource receiving module, configured to receive a response message sent by the resource server, wherein the response message includes the resource to be accessed;
[0028] The message forwarding module is used to forward the response message to the terminal.
[0029] According to one aspect of an embodiment of the present application, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the above-mentioned resource access method.
[0030] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the above-mentioned resource access method.
[0031] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned resource access method.
[0032] The technical solution provided in the embodiments of the present application can bring the following beneficial effects:
[0033] Taking advantage of the fact that direct server requests do not have a same-origin policy, a cross-domain proxy request is generated based on the resource request message sent by the target application, and a proxy identification parameter is added to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, ensuring that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed when the cache policy is set. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access, improving resource access efficiency, and ensuring the success rate and accuracy of resource access. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0035] Figure 1 is a schematic diagram of an application program operating environment provided by an embodiment of the present application;
[0036] Figure 2 A schematic diagram showing an example of applying the same-origin policy;
[0037] Figure 3 A network schematic diagram showing cross-domain resource sharing is exemplified;
[0038] Figure 4 is a flow chart of a resource access method provided by an embodiment of the present application;
[0039] Figure 5 A schematic diagram of a page for setting a cross-domain proxy mode is shown as an example;
[0040] Figure 6 is a flow chart of a resource access method provided by another embodiment of the present application;
[0041] Figure 7 is a flow chart of a resource access method provided by another embodiment of the present application;
[0042] Figure 8 A schematic diagram showing an exemplary resource access process in a cross-domain proxy mode;
[0043] Fig. 9 is a block diagram of a resource access device provided by an embodiment of the present application;
[0044] Fig.10 is a block diagram of a resource access device provided by another embodiment of the present application;
[0045] Fig.11is a structural block diagram of a computer device provided by an embodiment of the present application;
[0046] Fig.12 It is a structural block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0047] The embodiments of the present application relate to the cloud technology field and the blockchain technology field, which are briefly described below:
[0048] Cloud technology: A general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites, and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the backend system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0049] Cloud computing: refers to the delivery and use model of IT infrastructure, which means obtaining required resources through the network in an on-demand and easily scalable manner; in a broad sense, cloud computing refers to the delivery and use model of services, which means obtaining required services through the network in an on-demand and easily scalable manner. This service can be related to IT and software, the Internet, or other services. Cloud computing is the product of the integration of the development of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0050] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer. In a narrow sense, blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and a distributed ledger that is cryptographically guaranteed to be tamper-proof and unforgeable, that is, once the data in the blockchain is recorded, it will be irreversible.
[0051] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0052] Please refer to Figure 1 , which shows a schematic diagram of an application program running environment provided by an embodiment of the present application. The application program running environment may include: a terminal 10 and a server 20.
[0053] The terminal 10 may be an electronic device such as a mobile phone, a tablet computer, a game console, an e-book reader, a multimedia player, a wearable device, a PC (Personal Computer), etc. A client of an application program may be installed in the terminal 10 .
[0054] In the embodiment of the present application, the above-mentioned application can be any application that can send a network request. The network request can be sent directly to the resource server where the resource to be accessed is located, or it can request the resource to be accessed in the resource server through a proxy server. Typically, the application is an application development program, such as a low-code development platform. The target application quickly generated by the user in the low-code development platform can be debugged and previewed in the low-code development platform, and the network connection and data transmission are performed through the low-code development platform. The network request sent by the target application can be sent directly to the resource server that provides background services for the target application, or the background server of the low-code development platform can be used as a cloud proxy server to help the target application obtain the resource to be accessed in the resource server. Of course, in addition to the application development program, other types of applications can also send network requests. For example, browser applications, social applications, interactive entertainment applications, virtual reality (VR) applications, augmented reality (AR) applications, three-dimensional map programs, etc., the embodiment of the present application does not limit this. In addition, for different applications, the network requests sent and the network resources requested will also be different, which can be pre-configured according to actual needs, and the embodiment of the present application does not limit this. Optionally, a client of the above application program is running in the terminal 10 .
[0055] The server 20 is used to provide background services or cloud proxy services for the client of the application in the terminal 10. For example, the server 20 can be the background server of the above application, or a separate cloud proxy server. The server 20 can be a single server, or a server cluster composed of multiple servers, or a cloud computing service center. Optionally, the server 20 provides background services for the applications in multiple terminals 10 at the same time.
[0056] Optionally, the terminal 10 and the server 20 may communicate with each other via a network 30 .
[0057] Before introducing the method embodiments provided in the present application, a brief introduction is first given to the relevant terms or nouns that may be involved in the method embodiments of the present application to facilitate understanding by technicians in the field of the present application.
[0058] For computers and network devices to communicate with each other, both parties must use the same method. For example, how to detect the communication target, which side initiates the communication first, which language to use for communication, how to end the communication, and other rules all need to be determined in advance. Communication between different hardware and operating systems requires a rule. And we call this rule a protocol. TCP / IP is the general name for various Internet-related protocol families.
[0059] Hypertext Transfer Protocol (HTTP) is a request-response protocol that usually runs on top of TCP. It specifies what messages a client may send to a server and what responses it may get.
[0060] Cloud: refers to the online server.
[0061] Proxy server: It is a transfer station between the client and the server. When users access resources on the network, they can access the target resources through the proxy server and then return the corresponding results. Its basic behavior is to receive the request sent by the client and forward it to other servers. In the HTTP communication process, multiple proxy servers can be cascaded. The forwarding of requests and responses will pass through several proxy servers connected like a chain. When forwarding, it is necessary to attach a header field to mark the host information passed through.
[0062] The server that holds the resource entity is called the origin server. The response returned from the origin server is passed through the proxy server and then transmitted to the client.
[0063] Same-origin policy: refers to a web browser that allows a web page script to access data on another web page, but the premise is that the two web pages must have the same URI, host name and port number. Once two websites meet the above conditions, the two websites are considered to have the same origin. This policy prevents malicious scripts on a web page from accessing data on another web page through the document object model of the page. In an example, Figure 2 As shown, it exemplifies a schematic diagram of applying the same-origin policy. The domain name of the web page loaded by the browser in the terminal 20 is www.site-a.com. If the user requests resources from the server 21 whose domain name is also www.site-a.com through the web page, the browser can send a network request to the server 21 whose domain name is www.site-a.com through the terminal 20 to request the response resources. After receiving the request, the server 21 determines whether the domain name of the sender of the network request is consistent with the local domain name. If both are www.site-a.com, and the protocol version and port are consistent, a response message carrying the network resource corresponding to the network request will be sent to the terminal 20. If the user requests resources from the server 22 whose domain name is www.site-b.com through the web page, due to the restriction of the same-origin policy, that is, the domain name www.site-a.com of the web page is inconsistent with the domain name www.site-b.com of the server 22, this network request will fail.
[0064] Cross-Origin Resource Sharing (CORS) is a mechanism used to allow restricted resources of a web page to be accessed by pages on other domains. Through this mechanism, pages can freely use images, styles, scripts, iframes, and videos from different origins. Some cross-origin requests are often prohibited by the Same-origin policy. Cross-origin resource sharing defines a way for browsers and servers to confirm whether it is secure enough to use cross-origin requests. In an example, if Figure 3 As shown, it exemplarily shows a network schematic diagram of cross-domain resource sharing. A browser page 31 with a domain name of domain-a.com is displayed in the terminal 30. The image 32 in the browser page 31 is provided by a server 33 with a domain name of domain-a.com. The browser page 31 sends a request to obtain the image 32 to the server 33. After receiving the request, the server 33 sends the image 32 to the terminal 30. The image 34 in the browser page 31 is provided by a server 35 with a domain name of domain-b.com. Since the domain names of the server 35 and the browser page 31 are different, there is a homology policy restriction between the two. Therefore, the configuration information of cross-domain resource sharing needs to be set in the server 35. Only after the configuration information that allows the browser page 31 to perform cross-domain resource sharing is set in the server 35, the server 35 and the browser page 31 can break through the homology policy restriction between the two, and the terminal 30 sends a request to obtain the image 34 to the server 35. After receiving the request to obtain the image 34, the server 35 sends the image 34 to the terminal 30. In this way, the image 34 can be displayed normally in the browser page 31.
[0065] URI (Uniform Resource Identifier) specifies a unified format that can easily handle many different types of resources, without having to identify the access method specified by the resource based on the context. In addition, it is also easier to add new protocol schemes (such as http: or ftp:). The definition of Resource is "anything that can be identified." Not only document files, images or services (such as the day's weather forecast) that can be distinguished from other types can all be used as resources. In addition, resources can be not only single but also a collection of multiple ones. Identifier represents an identifiable object. It is also called an identifier. In summary, URI is a location identifier of a resource represented by a protocol scheme. The protocol scheme refers to the name of the protocol type used to access the resource.
[0066] URL (Uniform Resource Locator), URI uses a string to identify a certain Internet resource, and URL represents the location of the resource (the location on the Internet). It can be seen that URL is a subset of URI.
[0067] XMLHTTP is a set of API functions that can be called by JavaScript, JScript, VBScript and other scripting languages embedded in web browsers to send and receive XML or other data between browsers and web servers via HTTP. The biggest advantage of XMLHTTP is that it can dynamically update web pages without re-reading the entire web page from the server or installing additional plug-ins. This technology is used by many websites to implement fast-response dynamic web applications. For example: Google's Gmail service, Google Suggest dynamic search interface and Google Map geographic information service.
[0068] Ajax (Asynchronous JavaScript and XML) is an asynchronous communication method that effectively uses JavaScript and DOM (Document Object Model) to replace and load a partial Web page. Compared with the previous synchronous communication, since it only updates a part of the page, the amount of data transmitted in the response will be reduced, which is an obvious advantage. The core technology of Ajax is an API called XMLHttpRequest, which can communicate with the server through HTTP by calling the JavaScript scripting language. With this method, a request can be initiated from a loaded Web page to update only a partial page.
[0069] Please refer to Figure 4 , which shows a flow chart of a resource access method provided by an embodiment of the present application. The method can be applied to a computer device, which refers to an electronic device with data calculation and processing capabilities. For example, the execution subject of each step can be Figure 1 The terminal 10 in the application running environment is shown. The method may include the following steps (410-450).
[0070] Step 410: Obtain a resource request message sent by the target application.
[0071] Optionally, the target application is a debugging preview application in a program development application. The resource request message includes location information of a resource to be accessed.
[0072] A resource request message refers to a request message sent to request access to network resources on a server.
[0073] Optionally, a resource request message sent by the target application during the debugging and previewing process is obtained. The resource to be accessed is a network resource requested by the target application during the debugging and previewing process.
[0074] In one possible implementation, an application page of a program development application is loaded and displayed in the terminal, and a debugging preview page of a target application page is displayed in the application page of the program development application. A user can perform debugging operations in the debugging preview page of the target application. In the case where the user operation involves resource access, a corresponding resource access instruction will be triggered to be generated, and in response to the resource access instruction, the target application generates a resource request message. In order to obtain the resource to be accessed, the target application needs to send a resource request message to the server. The above-mentioned server can be a background server that provides network resource services for the target application, or it can be a cloud proxy server. Optionally, the background server of the program development application can serve as a proxy server for the target application.
[0075] In one possible implementation, the target application can send a resource request message by calling the request sending interface of the program development application. Optionally, the above-mentioned request sending interface is an application program interface set by the application development program for the target application to send a network request. The program development application intercepts the resource request message sent by the target application based on the request sending rules. Since the target application runs under the program development application, all APIs used by it are provided by the program development application. Therefore, the program development application side can intercept all HTTP requests of the target. For example, the HTTP request API provided by the program development application is app.request, and the code logic can be written in the app.requeset function method to intercept all requests.
[0076] Step 420: If the message sending mode of the resource request message is the cross-domain proxy mode, a proxy identification parameter is generated.
[0077] The message sending mode refers to the way in which the request message is sent to the server. Optionally, the message sending mode includes the same-domain sending mode and the cross-domain proxy mode. The above-mentioned same-domain sending mode refers to the sending mode in which the message sender and the message receiver comply with the same-origin policy, and the domain name, protocol, and port of the message sender and the message receiver are the same. The above-mentioned cross-domain proxy mode refers to the way in which the message sender and the message receiver transmit messages through a proxy service when any of the domain names, protocols, and ports of the message sender and the message receiver are different.
[0078] The proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache policy.
[0079] Cache refers to a copy of resources stored in the local disk of a proxy server or client. Using cache can reduce the access to the source server, thus saving communication traffic and communication time. The above cache strategy refers to pre-saving a copy (cache) of the resource on the proxy server or client. When the proxy server or client receives a request for the same resource again, it does not need to obtain the resource from the source server, but returns the previously cached resource as a response, reducing the traffic of network bandwidth.
[0080] Optionally, the cache has an expiration date. Even if there is a cache in the proxy server or client, there is no guarantee that requests for the same resource will be returned every time. Because this is related to the validity of the cached resources, when the resource on the source server is updated, if the unchanged cache is still used, it will become the "old" resource before the update. Even if there is a cache, the validity of the resource will be confirmed with the source server due to factors such as the client's requirements and the validity period of the cache. If the cache is judged to be invalid, the updated network resource will be obtained from the source server again.
[0081] Optionally, the request message contains a max-age directive, which specifies the survival time of the document after it is accessed. This time is a relative value, relative to the request time recorded by the server when the document is first requested. When the request sent by the client contains the max-age directive, if the cache time value of the cached resource is determined to be smaller than the specified time value, the client receives the cached resource. When the response returned by the server contains the max-age directive, the proxy server will no longer confirm the validity of the resource. The max-age value represents the maximum time the resource is saved as cache.
[0082] Since the proxy service interface address of the proxy server is fixed, the request path of each cross-domain proxy request (described below) sent by the client will point to this fixed proxy service interface address. The proxy server will determine the request path of the cross-domain proxy request, and it is easy to identify the cross-domain proxy request sent this time as the same request as the received cross-domain proxy request, and the request resource is the same, and then mistakenly return the proxy server cache content to the client, or mistakenly instruct the client to obtain the resource to be accessed from the client's local cache, resulting in the proxy server failing to correctly obtain the resource to be accessed from the resource server according to the cross-domain proxy request and forward it to the client. Schematically, if the response header of the corresponding response message of some cross-domain proxy requests is set with max-age=31536000, immutable (indicating strong cache), subsequent cross-domain proxy requests will never reach the proxy server again.
[0083] To avoid the above situation, a proxy identification parameter can be generated and added to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, so that the proxy server can still correctly obtain the resource to be accessed from the resource server according to the cross-domain proxy request and forward it to the client when setting the cache policy.
[0084] Optionally, the proxy identification parameter is a timestamp parameter. Optionally, the identification parameter is a randomly generated string. Optionally, the proxy identification parameter is a randomly generated digital sequence. In a possible implementation, the timestamp parameter is determined according to the moment information. For example, the timestamp parameter is determined according to the current moment.
[0085] Let's take an example to illustrate. The browser sends an HTTP request to www.a.com. Based on the HTTP request, the browser generates a cross-domain proxy request and sends the cross-domain proxy request to the proxy server for the first time. The request path of the cross-domain proxy request is www.lowcode.com / proxy, which is the interface address of the proxy service in the proxy server. The proxy server generates a response message for this cross-domain proxy request and sets the response header of the response message to tell the browser that this request address www.lowcode.com / proxy can be cached. When the browser sends an HTTP request to www.b.com, if the browser still generates a cross-domain proxy request with a request path of www.lowcode.com / proxy, the browser cannot obtain the network resources in www.b.com due to the cache strategy of the proxy server. At this time, a proxy identification parameter can be added to the request path, such as the timestamp parameter t=4564564654564, then the request path of the cross-domain proxy request is www.lowcode.com / proxy? t=456456465456. Due to the addition of the timestamp parameter, the request path of this cross-domain proxy request is different from that of the previous cross-domain proxy request. The cache can be refreshed forcibly to avoid the above situation. The proxy server will help the browser obtain the network resources in www.b.com, saving network transmission efficiency while still ensuring correct access to cross-domain resources.
[0086] In an exemplary embodiment, the location information includes second domain name information of the resource to be accessed, and the message sending mode of the resource request message can be determined by the following method.
[0087] Get the first domain name information of the target application; determine the message sending mode according to the second domain name information and the first domain name information; if the first domain name information is inconsistent with the second domain name information, determine that the message sending mode is the cross-domain proxy mode; if the first domain name information is consistent with the second domain name information, determine that the message sending mode is the same-domain sending mode. The above-mentioned first domain name information refers to the domain name information of the target application, and the above-mentioned second domain name information refers to the domain name information of the resource to be accessed. If the business server requested by the user is local (localhost / 127.0.0.1, local area network) or the business domain name is implemented by changing the local hosts, the server proxy forwarding cannot request the user's local server. At this time, the proxy request forwarding function not only does not help, but also blocks the development process and delays the development time. Through the client, it can intelligently determine whether to enable the cross-domain proxy mode to improve development efficiency and ensure smooth development.
[0088] In a possible implementation, the location information of the resource to be accessed is compared with the local network address to determine the message sending mode. Typically, the local network address is localhost / 127.0.0.1 / 10.*.*.1 / 192.168.*.*, where * represents any number. Alternatively, the local network address file is checked to see whether the network address in the local network address file matches the location information of the resource to be accessed. If the location information of the resource to be accessed matches the local network address, the message sending mode is determined to be the same-domain sending mode. If the location information of the resource to be accessed does not match the local network address, the message sending mode is determined to be the cross-domain proxy mode.
[0089] In one possible implementation, the location information of the resource to be accessed is compared with the domain name of the low-code development platform (i.e., the proxy server domain name) to determine the message sending mode. If the location information of the resource to be accessed matches the domain name of the low-code development platform, the message sending mode is determined to be the same-domain sending mode. If the location information of the resource to be accessed does not match the domain name of the low-code development platform, the message sending mode is determined to be the cross-domain proxy mode. In one possible implementation, in response to a setting instruction for the cross-domain proxy mode, the message sending mode is set to the cross-domain proxy mode. For example, in response to a click operation on the cross-domain proxy button in the application page, the message sending mode is set to the cross-domain proxy mode. In one example, as Figure 5 As shown, it exemplarily shows a schematic diagram of a page for setting a cross-domain proxy mode. The user can click the cross-domain request proxy button 51 in the application development program page 50 to keep the cross-domain request proxy button 51 in the turned-on state, and the target application in the debugging preview area 52 can access the corresponding network resources through the cross-domain proxy mode.
[0090] In another possible implementation, if the first domain name information is inconsistent with the second domain name information, the source information of the resource to be accessed is determined; if the source information includes the first domain name information, the message sending mode is determined to be the same-domain sending mode; if the source information does not include the first domain name information, the message sending mode is determined to be the cross-domain proxy mode. Here, the low-code development platform is taken as an example to illustrate the above steps. The user can upload the data source used by the target application in the low-code development platform, and the low-code development platform deploys the above data source to the business server. The low-code development platform can also store the above data source. The target application will be debugged and previewed before release. At this time, the data source can be in the proxy server or in the resource server. If the above source information indicates that the resource to be accessed comes from the above data source (that is, the source information includes the first domain name information), although the second domain name information is inconsistent with the first domain name information, the proxy server has the same resource to be accessed. At this time, the client can directly obtain the resource to be accessed from the proxy server (that is, determine that the message sending mode is the same-domain sending mode), and there is no need for the proxy server to obtain the resource to be accessed from the resource server.
[0091] Step 430: Generate a cross-domain proxy request according to the proxy identification parameter and the location information.
[0092] The above cross-domain proxy request is sent in the form of a request message, which consists of a request method, a request URI, a protocol version, an optional request header field, and a content entity. Among them, the type of request to access the server is called a request method. The string that indicates the resource object requested to access, such as / index.htm, is also called a request URI. The protocol version refers to the version number of HTTP, which is used to prompt the client to use the HTTP protocol function. In general, the meaning of the request content of the resource request message can be roughly understood as: requesting access to the / index.htm page resource on a certain HTTP server.
[0093] The request URI (or the target address URL) in the resource request message is stored in the request header of the request message, and the request URI (or the target address URL) in the resource request message is replaced with the interface address of the proxy server specifically used for proxy, and a cross-domain proxy request is generated. At this time, since the request domain name of the cross-domain proxy request is consistent with the domain name of the proxy server, the cross-domain proxy request will not be affected by the same-origin policy, and the resource server does not need to set up additional cross-origin resource sharing (CORS) configuration, and can access resources normally through the proxy server.
[0094] In a possible implementation, target address information is generated according to the address of the proxy server and the proxy identification parameter; and a cross-domain proxy request is generated based on the target address information and the location information.
[0095] The target address information is the request path information of the cross-domain proxy request. Optionally, the target address information is composed of the address of the proxy server and the proxy identification parameter. The location information is the location information of the resource to be accessed, and the location information of the resource to be accessed is stored in the request header of the cross-domain proxy request.
[0096] In an exemplary embodiment, the address of the proxy server and the proxy identification parameter are concatenated to generate the target address information of the cross-domain proxy request.
[0097] In an exemplary embodiment, the receiving address information of the resource request message is replaced by the location information of the resource to be accessed, and the location information of the resource to be accessed is then stored in the request header of the resource request message to generate a cross-domain proxy request.
[0098] In a possible implementation, the application development program is taken as a low-code development platform as an example. The low-code development platform can be integrated into other application platforms as a function in other application platforms. If the domain name of the other application platform is www.x.com, then the domain name of the low-code development platform is www.x.com / lowcode, and the proxy interface address of the low-code development platform is www.x.com / lowcode / proxy. At this time, the target address information of the cross-domain proxy request is obtained by concatenating the proxy interface address of the low-code development platform with the above timestamp parameter.
[0099] In an exemplary embodiment, the resource request message further includes an application identification parameter of the target application. The application identification parameter is a unique code that characterizes the target application to distinguish other applications. The address of the proxy server can be determined in the following manner.
[0100] Obtain proxy authorization information, which represents the mapping relationship between each application and the proxy server authorized by each application; determine the target proxy server authorized by the target application based on the application identification parameter and the proxy authorization information; accordingly, concatenate the address of the target proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request. The target proxy server may be a proxy server authorized by the target application in a proxy server cluster, and the proxy server cluster may be a cluster composed of various backend servers of a low-code development platform, with proxy services provided by various backend servers of the low-code development platform. The address of the target proxy server may be the interface address of the proxy interface of the target proxy server, and the proxy interface may be a proxy interface authorized by the target application among various proxy interfaces of the target proxy server. The address of the target proxy server may also be the interface address of a container deployed in the target proxy server to run the proxy service, and the container may be a container authorized by the target application among various containers of the target proxy server.
[0101] In a possible implementation, the client of the application development program is implemented based on browser technology, and the client of the application development program can be a front-end page loaded by the browser. The target application can be debugged and previewed in the iframe tag in the browser. If the target application needs to call the request sending interface of the browser to send a resource acquisition request, the request sending interface of the browser only recognizes the data under the browser's own application program, and does not recognize the data in the iframe tag in the browser, that is, the data of the target application.
[0102] In an exemplary embodiment, the associated data of the resource to be accessed is obtained in the target application; the associated data is processed for compatibility to generate target data consistent with the content of the associated data; and the target data is added to the cross-domain proxy request. The above-mentioned compatibility processing is used to generate data that conforms to the data carrying rules of the cross-domain proxy request to ensure successful resource access and avoid the loss of key data information in the resource request message in the cross-domain proxy request.
[0103] Optionally, the above-mentioned compatibility processing includes but is not limited to operations such as copying, encryption, and format conversion. In one possible implementation, the associated data is copied, and target data consistent with the associated data content is generated in a program development application (which may be a low-code development platform based on a browser), so that the target data can be successfully added to the cross-domain proxy request.
[0104] Optionally, the above-mentioned associated data is encrypted data, and the program development application and the proxy server cannot identify the above-mentioned associated data, thereby ensuring the security of the data in the target application. The above-mentioned associated data can be identified by the resource server.
[0105] The embodiment of the present application performs compatibility processing on the data involving the form type in the target application embedded in the browser, and regenerates the target data associated with the resource to be accessed in the target application in the program development application loaded by the browser, so that the browser's request sending interface is recognized, ensuring that the resource access request is sent completely, and avoiding the loss of the target data associated with the resource to be accessed in the target application.
[0106] Schematically, the above process is illustrated by an example. The FormData (FormData provides a construction method for key-value pairs representing form data) of the target application embedded in the program development application belongs to iframeA (target application), and the FormData of the program development application belongs to iframeB. The target application can only send resource access requests through the XMLHttpRequest method of the program development application, but the XMLHttpRequest method of the program development application only recognizes the FormData created from the program development application (iframeB). To ensure that the FormData in iframeA is not lost, the program development application copies the FormData in iframeA and regenerates it in iframeB. In this way, the resource access message sent through the XMLHttpRequest method carries the data content of the FormData in iframeA, thereby ensuring successful access to resources.
[0107] The above target data may be account number, password, identity identification and other information.
[0108] Step 440: Send the cross-domain proxy request to the proxy server.
[0109] In a possible implementation, if the message sending mode is the same domain sending mode, a proxy identification parameter is generated; an updated resource request message is generated according to the proxy identification parameter and the source information; the updated resource request message is sent to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the updated resource request message when the proxy server sets a cache policy. Optionally, the address of the proxy server represented by the source information and the proxy identification parameter are spliced to generate the target address information of the updated resource request message; the receiving address information of the resource request message is replaced by the location information of the resource to be accessed with the target address information of the updated resource request message; the source information and location information of the resource to be accessed are stored in the request header of the updated resource request message to generate an updated resource request message; the associated data of the resource to be accessed is obtained in the target application; the associated data is compatible processed to generate target data consistent with the content of the associated data, and the above-mentioned compatible processing is used to generate data that conforms to the data carrying rules of the updated resource request message; the target data is added to the updated resource request message. Send the updated resource request message to the proxy server.
[0110] In an exemplary embodiment, proxy authorization information is obtained, the proxy authorization information represents the mapping relationship between each application and the proxy server authorized by the application; based on the application identification parameter and the proxy authorization information, the target proxy server authorized by the target application is determined, the above-mentioned target proxy server includes the resources to be accessed, and the above-mentioned source information can represent the address of the target proxy server; the address of the target proxy server and the proxy identification parameter are concatenated to generate the target address information of the updated resource request message.
[0111] Step 450: Receive a response message sent by the proxy server.
[0112] The response message includes the resource to be accessed, and sends the resource to be accessed to the target application.
[0113] In another possible implementation, if the message sending mode is the same-domain sending mode, a resource request message is sent to a resource server; and a response message sent by the resource server is received, where the response message sent by the resource server includes the resource to be accessed.
[0114] In an exemplary embodiment, the debugging preview page of the target application is updated according to the resource to be accessed.
[0115] The updating of the debugging preview page of the target application may be to display new content in the debugging preview page, or to switch between application pages of the target application.
[0116] Optionally, the resource to be accessed includes authorization information. For example, a program developer enters an account and password in the debug preview page of the target application and clicks a login control to trigger an account login request, which is used to request the resource server to send login authorization information; after the client receives the authorization information, the debug preview page jumps from the login page of the target application to the application main page of the target application.
[0117] Optionally, the resource to be accessed includes multimedia resource data. The client can display the content loaded by the multimedia resource data on the debugging preview page of the target application, such as playing video, playing audio, displaying text content, etc.
[0118] To sum up, the technical solution provided by the embodiment of the present application utilizes the characteristic that direct server requests do not have a same-origin policy, generates a cross-domain proxy request based on the resource request message sent by the target application, and adds a proxy identification parameter to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, thereby ensuring that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed when the cache policy is set. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access, improving resource access efficiency, and ensuring the success rate and accuracy of resource access.
[0119] Please refer to Figure 6 , which shows a flow chart of a resource access method provided by another embodiment of the present application. The method can be applied to a computer device, which refers to an electronic device with data calculation and processing capabilities. For example, the execution subject of each step can be Figure 1 The server 20 in the application running environment is shown. The method may include the following steps (610-650).
[0120] Step 610: Receive a cross-domain proxy request.
[0121] The cross-domain proxy request includes a proxy identification parameter and the location information of the resource to be accessed. The proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the cache policy is set. The access resource refers to the network resource requested by the target application during the debugging preview process.
[0122] Optionally, the cross-domain proxy request is received by a target proxy server in the proxy server cluster that is authorized by the target application. Optionally, the cross-domain proxy request is received by a proxy interface that is authorized by the target application. Optionally, the cross-domain proxy request is received by a container running a proxy service that is authorized by the target application.
[0123] Step 620: Generate a resource acquisition request based on the location information of the resource to be accessed.
[0124] In one possible implementation, after the low-code development platform server receives the cross-domain proxy request, it obtains the location information of the resource to be accessed in the resource access message from the request header.
[0125] Based on the location information of the resource to be accessed, the path (pathname), protocol (protocol), port (port) and parameters (search) of the cross-domain proxy request are rewritten to generate a resource acquisition request.
[0126] At this time, we use the feature that requests between servers are not restricted by the browser's homology policy, because the homology policy is mainly aimed at browsers, which prevents malicious scripts on a web page from accessing data on another web page through the document object model of the page. Requests between servers do not have this restriction.
[0127] In an exemplary embodiment, the above step 620 may be implemented as follows.
[0128] Generate verification authorization parameters according to the authorization information of the resource server; based on the location information of the resource to be accessed, change the receiving address information of the cross-domain proxy request to generate the receiving address information of the resource acquisition request; add the security verification parameters to the request header of the cross-domain proxy request to generate a resource acquisition request.
[0129] Optionally, the authorization information of the resource server is preset, and the authorization information of the resource server may include the information of the proxy server, to indicate that the resource server trusts the proxy server and can provide the proxy server with corresponding network services and network resources. When the proxy server calls the interface of the resource server, in order to identify itself to the resource server, it is necessary to add a verification authorization parameter to the request header of the resource acquisition request, so that the resource server can quickly and securely verify the resource acquisition request and avoid a complicated login verification process.
[0130] The verification authorization parameter is used to indicate the security of the resource acquisition request to the resource server, so that the resource server cancels the verification process for the resource acquisition request.
[0131] Optionally, the verification authorization parameters include a signature parameter of the proxy server, a timestamp parameter, randomly generated interference characters, an application identification parameter, and a secret key parameter. The signature parameter is used to characterize the identity information of the proxy server. The timestamp parameter is used to characterize the moment information of the resource acquisition request and can be used to characterize the timeliness of the resource acquisition request. The randomly generated interference characters are used to prevent information leakage. The application identification parameter is used to characterize the identity information of the application requesting the resource to be accessed. The secret key parameter is used to encrypt the information of the resource acquisition request, and the resource server can read the information of the resource acquisition request according to the secret key parameter and the preset security rules.
[0132] Step 630: Send a resource acquisition request to a resource server.
[0133] Using the fact that requests between servers are not restricted by the browser's same-origin policy, resource acquisition requests are sent to the resource server. Because the same-origin policy is mainly aimed at browsers, it prevents malicious scripts on a web page from accessing data on another web page through the document object model of the page. Requests between servers do not have this restriction.
[0134] In an exemplary embodiment, the proxy server and the resource server may be different virtual servers on the same server.
[0135] Step 640: Receive a response message sent by the resource server.
[0136] The response message includes the resource to be accessed;
[0137] Step 650: forward the response message to the terminal.
[0138] The response message is forwarded to the terminal so that the terminal updates the debugging preview page of the target application according to the resource to be accessed.
[0139] In a possible implementation, after receiving the response message sent by the resource server, the proxy server may modify the resource to be accessed, and send the modified resource to be accessed to the terminal.
[0140] In one possible implementation, the proxy server stores resources to be accessed, and the source information of the resources to be accessed indicates that the source of the resources to be accessed is the data source sent by the target application to the low-code development platform. After the proxy server receives the resource request message (i.e., the updated resource request message in the above embodiment), it sends a response message to the terminal, and the response message sent by the proxy server includes the resources to be accessed.
[0141] In summary, the technical solution provided by the embodiment of the present application utilizes the characteristic that direct server requests do not have a homology policy, and can successfully receive a cross-domain proxy request with a proxy identification parameter representing the uniqueness of the request when the proxy server sets a cache policy, and generate a resource acquisition request according to the cross-domain proxy request to obtain the correct resource to be accessed from the resource server, and then return the resource to be accessed to the requesting terminal, without the need for cross-domain resource sharing configuration, to achieve resource access, reduce the complexity of resource access, improve resource access efficiency, and ensure the success rate and accuracy of resource access.
[0142] Please refer to Figure 7, which shows a flow chart of a resource access method provided by another embodiment of the present application. The method can be applied to a resource access system, wherein the resource access system includes a terminal, a proxy server, and a resource server. The method may include the following steps (701-716).
[0143] Step 701: The terminal displays an application page.
[0144] The application page includes a debugging preview page of the target application. Optionally, the application page is an application page of a program development application.
[0145] Step 702: The terminal generates a resource request message in response to a resource access instruction of the target application.
[0146] The resource request message includes the location information of the resource to be accessed.
[0147] Step 703: The terminal target application sends a resource request message through a request sending interface.
[0148] Step 704: The terminal intercepts the resource request message based on the request sending rule.
[0149] Step 705: The terminal obtains the first domain name information of the target application.
[0150] Step 706: The terminal determines a message sending mode according to the second domain name information and the first domain name information.
[0151] If the first domain name information is inconsistent with the second domain name information, it is determined that the message sending mode is a cross-domain proxy mode.
[0152] If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same domain sending mode.
[0153] Step 707: If the message sending mode of the resource request message is the cross-domain proxy mode, the terminal generates a proxy identification parameter.
[0154] The proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache policy.
[0155] Step 708: The terminal generates target address information according to the address of the proxy server and the proxy identification parameter.
[0156] Step 709: The terminal generates a cross-domain proxy request based on the target address information and the location information.
[0157] Step 710: The terminal copies the associated data of the resource to be accessed in the target application, and generates target data consistent with the content of the associated data.
[0158] Step 711: The terminal adds the target data to the cross-domain proxy request.
[0159] Step 712: Send the cross-domain proxy request to the proxy server.
[0160] Accordingly, the proxy server receives the cross-domain proxy request.
[0161] The cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed. The proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set.
[0162] Step 713: The proxy server generates a resource acquisition request based on the location information of the resource to be accessed.
[0163] Step 714: The proxy server sends a resource acquisition request to the resource server.
[0164] Accordingly, the resource server receives the resource acquisition request.
[0165] Step 715: The resource server sends a response message to the proxy server.
[0166] Correspondingly, the proxy server receives the response message sent by the resource server.
[0167] Step 716: The proxy server forwards the response message to the terminal.
[0168] Correspondingly, the terminal receives the response message sent by the proxy server.
[0169] The response message includes the resource to be accessed.
[0170] In one example, if Figure 8As shown, it exemplifies a schematic diagram of the resource access process in the cross-domain proxy mode. Among them, the low-code development platform client 80 can be a browser front-end page; the real-time preview page 81 of the business application is displayed in the low-code development platform client 80; the business application refers to the business application that the user needs to develop under the low-code development platform; the business server 82 refers to the server that provides network services for the business application according to the user's business logic, and its domain name is generally not the same as the domain name of the low-code development platform client 80; the low-code development platform server 83 refers to the server that provides background services for the low-code development platform client 80, which can be used as a proxy server for the business application here to realize the cloud proxy function of the low-code development platform. The domain name of the low-code development platform client 80 is lowcode.com, and accordingly, the domain name of the low-code development platform server 83 is also owcode.com. The domain name of the business server 82 is business.com. When the business application is actually deployed, the domain name of the business application is the same as the domain name of the business server 82, both of which are business.com. However, at this time, because the business application is debugged and previewed in the low-code development platform client 80, the domain name of the business application is the same as the domain name of the low-code development platform client 80, which is lowcode.com. The user can perform operations on the real-time preview page 81 of the business application, thereby triggering the resource access process of the business application, and the business application generates a business request to obtain the corresponding network resources. If the business application sends a business request directly to the business server 82 through the low-code development platform client 80 or the business application itself, due to the browser's homology policy restrictions and the lack of cross-domain resource sharing configuration information in the business server 82, the response information of the business server 82 cannot be sent to the business application. In order to solve the above problem, the low-code development platform client 80 can intercept the business request sent by the business application, change the request path of the business request to the cloud proxy interface address in the low-code development platform server 83, and save the original request path of the business request, generate a proxy request and send the proxy request to the low-code development platform server 83. In this way, the browser's homology policy is satisfied, the sending of network requests with the same domain name is not restricted, and the low-code development platform server 83 can smoothly receive the proxy request. After receiving the proxy request, the low-code development platform server 83 sends a resource acquisition request to the business server based on the original request path of the business request saved in the proxy request. Since there is no homology policy restriction on requests between servers, the business server 82 can successfully receive the resource acquisition request and send the response information to the low-code development platform server 83.After receiving the response information, the low-code development platform server 83 can forward the response information to the business application in the low-code development platform client 80. In this way, the business application can successfully access the network resources in the business server 82 that is not configured for cross-domain resource sharing.
[0171] In an exemplary embodiment, if the message sending mode is the same-domain sending mode, the terminal sends a resource request message to the resource server; the resource server sends a response message to the terminal; the terminal receives the response message sent by the resource server, and the response message sent by the resource server includes the resource to be accessed.
[0172] To sum up, the technical solution provided by the embodiment of the present application utilizes the characteristic that direct server requests do not have a same-origin policy, generates a cross-domain proxy request based on the resource request message sent during the debugging and previewing process of the target application, and adds a proxy identification parameter to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, thereby ensuring that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed when the cache policy is set. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of debugging and previewing of the application, improving the resource access efficiency of the application during debugging and previewing, and ensuring the success rate and accuracy of resource access.
[0173] In addition, the technical solution of the embodiment of the present application is applied to the low-code program development scenario. Through the cloud proxy, the resource access request of the target application is handed over to the low-code development platform server agent, breaking through the limitations of the browser's same-origin policy to request resources from different source domain names. There is no need for the server of the target application to set up additional cross-domain resource sharing (CORS) configuration, and the effect preview and interface debugging of the application can be completed on the low-code development platform, which lowers the application debugging threshold and speeds up the application development efficiency.
[0174] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0175] Please refer to Fig. 9 , which shows a block diagram of a resource access device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned resource access method, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be a computer device, or it can be set in a computer device. The device 900 may include: a request acquisition module 910, an identification generation module 920, a proxy request generation module 930, a request sending module 940 and a message receiving module 950.
[0176] The request acquisition module 910 is used to acquire a resource request message sent by a target application, wherein the resource request message includes location information of a resource to be accessed;
[0177] The identification generating module 920 is used to generate a proxy identification parameter if the message sending mode of the resource request message is a cross-domain proxy mode;
[0178] A proxy request generating module 930, configured to generate a cross-domain proxy request according to the proxy identification parameter and the location information;
[0179] A request sending module 940 is used to send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache policy;
[0180] The message receiving module 950 is used to receive a response message sent by the proxy server, wherein the response message includes the resource to be accessed.
[0181] In an exemplary embodiment, the proxy request generation module 930 includes an address generation unit, an address replacement unit, and a proxy request generation unit.
[0182] The address generating unit is used to perform concatenation processing on the address of the proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request.
[0183] The address replacement unit is used to replace the receiving address information of the resource request message with the location information of the resource to be accessed into the target address information.
[0184] The proxy request generating unit is used to store the location information of the resource to be accessed into the request header of the resource request message to generate the cross-domain proxy request.
[0185] In an exemplary embodiment, the resource request message further includes an application identification parameter of the target application, and the proxy request generation module 930 further includes:
[0186] The authorization information acquisition unit is used to acquire proxy authorization information, wherein the proxy authorization information represents a mapping relationship between each application and a proxy server authorized by each application.
[0187] A server determination unit, configured to determine a target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information;
[0188] Accordingly, the address generating unit is further used for:
[0189] The address of the target proxy server and the proxy identification parameter are concatenated to generate target address information of the cross-domain proxy request.
[0190] In an exemplary embodiment, the proxy request generating module 930 further includes: a data acquiring unit, a data compatibility processing unit, and a data adding unit.
[0191] A data acquisition unit is used to acquire the associated data of the resource to be accessed in the target application.
[0192] The data compatibility processing unit is used to perform compatibility processing on the associated data to generate target data consistent with the content of the associated data, and the compatibility processing is used to generate data that complies with the data carrying rules of the cross-domain proxy request.
[0193] A data adding unit is used to add the target data to the cross-domain proxy request.
[0194] In an exemplary embodiment, the location information includes second domain name information of the resource to be accessed, and the device 900 further includes: a domain name acquisition module and a mode determination module.
[0195] A domain name acquisition module, used to acquire the first domain name information of the target application;
[0196] A mode determination module is used to determine the message sending mode according to the second domain name information and the first domain name information.
[0197] In an exemplary embodiment, the mode determination module is used to:
[0198] If the first domain name information is inconsistent with the second domain name information, the message sending mode is determined to be the cross-domain proxy mode; or, if the first domain name information is inconsistent with the second domain name information, the source information of the resource to be accessed is determined; if the source information includes the first domain name information, the message sending mode is determined to be the same-domain sending mode; if the source information does not include the first domain name information, the message sending mode is determined to be the cross-domain proxy mode; if the first domain name information is consistent with the second domain name information, the message sending mode is determined to be the same-domain sending mode.
[0199] In an exemplary embodiment, the request sending module 940 is further configured to:
[0200] If the message sending mode is the same-domain sending mode, sending the resource request message to the resource server;
[0201] The message receiving module 950 is further used for:
[0202] A response message sent by the resource server is received, where the response message sent by the resource server includes the resource to be accessed.
[0203] In an exemplary embodiment, the device 900 further includes: a page display module and an application request generation module.
[0204] A page display module, used to display an application page, wherein the application page includes a debugging preview page of the target application;
[0205] The application request generating module is used to generate the resource request message in response to the resource access instruction of the target application.
[0206] The request acquisition module 910 includes: an application request pre-sending unit and a request intercepting unit.
[0207] An application request pre-sending unit, used for the target application to send the resource request message through a request sending interface;
[0208] The request interception unit is used to intercept the resource request message based on the request sending rule.
[0209] To sum up, the technical solution provided by the embodiment of the present application utilizes the characteristic that direct server requests do not have a same-origin policy, generates a cross-domain proxy request based on the resource request message sent by the target application, and adds a proxy identification parameter to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, thereby ensuring that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed when the cache policy is set. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access, improving resource access efficiency, and ensuring the success rate and accuracy of resource access.
[0210] Please refer to Fig.10 , which shows a block diagram of a resource access device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned resource access method, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be a computer device, or it can be set in a computer device. The device 1000 may include: a request receiving module 1010, a resource request generating module 1020, a resource request sending module 1030, a resource receiving module 1040 and a message forwarding module 1050.
[0211] A request receiving module 1010 is used to receive a cross-domain proxy request, wherein the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set;
[0212] A resource request generating module 1020, configured to generate a resource acquisition request based on the location information of the resource to be accessed;
[0213] The resource request sending module 1030 is used to send the resource acquisition request to the resource server;
[0214] The resource receiving module 1040 is used to receive a response message sent by the resource server, wherein the response message includes the resource to be accessed;
[0215] The message forwarding module 1050 is used to forward the response message to the terminal.
[0216] In an exemplary embodiment, the resource request generation module 1020 includes a parameter generation unit, an address change unit, and a request generation unit.
[0217] A parameter generation unit, used to generate verification authorization parameters according to the authorization information of the resource server;
[0218] An address changing unit, configured to change the receiving address information of the cross-domain proxy request based on the location information of the resource to be accessed, and generate the receiving address information of the resource acquisition request;
[0219] The request generation unit is used to add the security verification parameter to the request header of the cross-domain proxy request to generate the resource acquisition request.
[0220] In summary, the technical solution provided by the embodiment of the present application utilizes the characteristic that direct server requests do not have a homology policy, and can successfully receive a cross-domain proxy request with a proxy identification parameter representing the uniqueness of the request when the proxy server sets a cache policy, and generate a resource acquisition request according to the cross-domain proxy request to obtain the correct resource to be accessed from the resource server, and then return the resource to be accessed to the requesting terminal, without the need for cross-domain resource sharing configuration, to achieve resource access, reduce the complexity of resource access, improve resource access efficiency, and ensure the success rate and accuracy of resource access.
[0221] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0222] Please refer to Fig.11, which shows a structural block diagram of a computer device provided in one embodiment of the present application. The computer device may be a terminal. The computer device is used to implement the resource access method on the terminal side provided in the above embodiment. Specifically:
[0223] Typically, the computer device 1100 includes a processor 1101 and a memory 1102 .
[0224] The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1101 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1101 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1101 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0225] The memory 1102 may include one or more computer-readable storage media, which may be non-transitory. The memory 1102 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is configured to be executed by one or more processors to implement the above-mentioned client-side text generation method.
[0226] In some embodiments, the computer device 1100 may also optionally include: a peripheral device interface 1103 and at least one peripheral device. The processor 1101, the memory 1102 and the peripheral device interface 1103 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1103 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1104, a touch display screen 1105, a camera assembly 1106, an audio circuit 1107, a positioning assembly 1108 and a power supply 1109.
[0227] Those skilled in the art will understand that Fig.11 The structure shown in the figure does not constitute a limitation on the computer device 1100, and the computer device 1100 may include more or less components than shown in the figure, or combine some components, or adopt a different component arrangement.
[0228] Please refer to Fig.12 , which shows a structural block diagram of a computer device provided in one embodiment of the present application. The computer device may be a server, and the computer device is used to implement the resource access method on the server side provided in the above embodiment. Specifically:
[0229] The computer device 1200 includes a central processing unit (CPU) 1201, a system memory 1204 including a random access memory (RAM) 1202 and a read only memory (ROM) 1203, and a system bus 1205 connecting the system memory 1204 and the central processing unit 1201. The computer device 1200 also includes a basic input / output system (I / O (Input / Output) system) 1206 that helps to transfer information between various components in the computer, and a large-capacity storage device 1207 for storing an operating system 1213, application programs 1214, and other program modules 1212.
[0230] The basic input / output system 1206 includes a display 1208 for displaying information and an input device 1209 such as a mouse and a keyboard for user inputting information. The display 1208 and the input device 1209 are connected to the central processing unit 1201 through an input / output controller 1210 connected to the system bus 1205. The basic input / output system 1206 may also include an input / output controller 1210 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1210 also provides output to a display screen, a printer, or other types of output devices.
[0231] The mass storage device 1207 is connected to the central processing unit 1201 through a mass storage controller (not shown) connected to the system bus 1205. The mass storage device 1207 and its associated computer readable media provide non-volatile storage for the computer device 1200. That is, the mass storage device 1207 may include a computer readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0232] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above. The above-mentioned system memory 1204 and mass storage device 1207 can be collectively referred to as memory.
[0233] According to various embodiments of the present application, the computer device 1200 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 1200 can be connected to the network 1212 through the network interface unit 1211 connected to the system bus 1205, or the network interface unit 1211 can be used to connect to other types of networks or remote computer systems (not shown).
[0234] The memory also includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the resource access method.
[0235] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and when the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the above-mentioned resource access method is implemented.
[0236] Optionally, the computer readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives) or optical disks, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0237] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned resource access method.
[0238] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.
[0239] In addition, in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0240] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A resource access method, characterized in that: The method comprises: Obtaining a resource request message sent by a target application, wherein the resource request message includes location information of a resource to be accessed; If the message sending mode of the resource request message is a cross-domain proxy mode, a proxy identification parameter is generated; a cross-domain proxy request is generated according to the proxy identification parameter and the location information; the cross-domain proxy request is sent to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a cache strategy; the cache strategy is to cache a copy of the resource on the proxy server or the client in advance; Receiving a response message sent by the proxy server, wherein the response message includes the resource to be accessed; Among them, generating a cross-domain proxy request according to the proxy identification parameter and the location information includes: concatenating the address of the proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request; replacing the receiving address information of the resource request message with the location information of the resource to be accessed by the target address information; storing the location information of the resource to be accessed in the request header of the resource request message to generate the cross-domain proxy request.
2. The method according to claim 1, characterized in that The resource request message also includes an application identification parameter of the target application. Before the address of the proxy server and the proxy identification parameter are concatenated to generate the target address information of the cross-domain proxy request, the following further includes: Acquire proxy authorization information, where the proxy authorization information represents a mapping relationship between each application and a proxy server authorized by each application; Determining a target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information; Accordingly, the address of the proxy server and the proxy identification parameter are concatenated to generate the target address information of the cross-domain proxy request, including: The address of the target proxy server and the proxy identification parameter are concatenated to generate target address information of the cross-domain proxy request.
3. The method according to claim 1, characterized in that The generating a cross-domain proxy request according to the proxy identification parameter and the location information further includes: Acquire, in the target application, associated data of the resource to be accessed; Performing compatibility processing on the associated data to generate target data consistent with the content of the associated data, wherein the compatibility processing is used to generate data that complies with the data carrying rules of the cross-domain proxy request; The target data is added to the cross-domain proxy request.
4. The method according to claim 1, characterized in that: The location information includes second domain name information of the resource to be accessed, and the method further includes: Obtaining first domain name information of the target application; If the first domain name information is inconsistent with the second domain name information, the message sending mode is determined to be the cross-domain proxy mode; or, if the first domain name information is inconsistent with the second domain name information, the source information of the resource to be accessed is determined; if the source information includes the first domain name information, the message sending mode is determined to be the same-domain sending mode; if the source information does not include the first domain name information, the message sending mode is determined to be the cross-domain proxy mode; If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same-domain sending mode.
5. The method according to claim 4, characterized in that The method further comprises: If the message sending mode is the same-domain sending mode, sending the resource request message to the resource server; A response message sent by the resource server is received, where the response message sent by the resource server includes the resource to be accessed.
6. The method according to any one of claims 1 to 5, characterized in that: Before obtaining the resource request message, it also includes: Displaying an application page, wherein the application page includes a debugging preview page of the target application; generating the resource request message in response to the resource access instruction of the target application; The resource acquisition request message includes: The target application sends the resource request message through a request sending interface; Based on the request sending rule, the resource request message is intercepted.
7. A resource access method, characterized in that: The method comprises: A cross-domain proxy request is received, wherein the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache strategy is set; the cross-domain proxy request is obtained by storing the location information of the resource to be accessed in a request header of a resource request message, wherein the location information of the resource to be accessed is obtained by replacing the receiving address information of the resource request message with the location information of the resource to be accessed with the target address information of the cross-domain proxy request, wherein the target address information is obtained by concatenating the address of the proxy server and the proxy identification parameter; and the cache strategy is to pre-cache a copy of the resource on the proxy server or the client; Generate a resource acquisition request based on the location information of the resource to be accessed; Sending the resource acquisition request to a resource server; Receiving a response message sent by the resource server, wherein the response message includes the resource to be accessed; Forward the response message to the terminal.
8. The method according to claim 7, characterized in that The generating a resource acquisition request based on the location information of the resource to be accessed includes: Generating verification authorization parameters according to the authorization information of the resource server; Based on the location information of the resource to be accessed, the receiving address information of the cross-domain proxy request is changed to generate the receiving address information of the resource acquisition request; The verification authorization parameter is added to the request header of the cross-domain proxy request to generate the resource acquisition request.
9. A resource access device, characterized in that: The device comprises: A request acquisition module, used to acquire a resource request message sent by a target application, wherein the resource request message includes location information of a resource to be accessed; An identification generating module, configured to generate an agent identification parameter if the message sending mode of the resource request message is a cross-domain agent mode; A proxy request generation module, used to generate a cross-domain proxy request according to the proxy identification parameter and the location information, the proxy request generation module includes an address generation unit, an address replacement unit and a proxy request generation unit, the address generation unit is used to perform splicing processing on the address of the proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request; the address replacement unit is used to replace the receiving address information of the resource request message with the location information of the resource to be accessed, and the target address information; the proxy request generation unit is used to store the location information of the resource to be accessed in the request header of the resource request message to generate the cross-domain proxy request; A request sending module, used for sending the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used for identifying the uniqueness of the cross-domain proxy request when the proxy server sets a cache strategy; the cache strategy is to cache a copy of the resource in advance on the proxy server or the client; The message receiving module is used to receive a response message sent by the proxy server, wherein the response message includes the resource to be accessed.
10. The device according to claim 9, characterized in that The resource request message also includes an application identification parameter of the target application, and the proxy request generation module also includes: An authorization information acquisition unit, used to acquire proxy authorization information, wherein the proxy authorization information represents a mapping relationship between each application and a proxy server authorized by each application; A server determination unit, configured to determine a target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information; Accordingly, the address generating unit is further used for: The address of the target proxy server and the proxy identification parameter are concatenated to generate target address information of the cross-domain proxy request.
11. The device according to claim 9, characterized in that The proxy request generation module also includes: a data acquisition unit, a data compatibility processing unit and a data adding unit; A data acquisition unit, used for acquiring the associated data of the resource to be accessed in the target application; A data compatibility processing unit, configured to perform compatibility processing on the associated data to generate target data consistent with the content of the associated data, wherein the compatibility processing is used to generate data that complies with the data carrying rules of the cross-domain proxy request; A data adding unit is used to add the target data to the cross-domain proxy request.
12. The device according to claim 9, characterized in that The location information includes the second domain name information of the resource to be accessed, and the device further includes: a domain name acquisition module and a mode determination module; A domain name acquisition module, used to acquire the first domain name information of the target application; A mode determination module, used to determine the message sending mode according to the second domain name information and the first domain name information; The mode determination module is used to: If the first domain name information is inconsistent with the second domain name information, the message sending mode is determined to be the cross-domain proxy mode; or, if the first domain name information is inconsistent with the second domain name information, the source information of the resource to be accessed is determined; if the source information includes the first domain name information, the message sending mode is determined to be the same-domain sending mode; if the source information does not include the first domain name information, the message sending mode is determined to be the cross-domain proxy mode; if the first domain name information is consistent with the second domain name information, the message sending mode is determined to be the same-domain sending mode.
13. The device according to claim 12, characterized in that The request sending module is also used for: If the message sending mode is the same-domain sending mode, sending the resource request message to the resource server; The message receiving module is further used for: A response message sent by the resource server is received, where the response message sent by the resource server includes the resource to be accessed.
14. The device according to any one of claims 9 to 13, characterized in that: The device also includes a page display module and an application request generation module; A page display module, used to display an application page, wherein the application page includes a debugging preview page of the target application; An application request generating module, configured to generate the resource request message in response to the resource access instruction of the target application; The request acquisition module includes: an application request pre-sending unit and a request intercepting unit; An application request pre-sending unit, used for the target application to send the resource request message through a request sending interface; The request interception unit is used to intercept the resource request message based on the request sending rule.
15. A resource access device, characterized in that: The device comprises: A request receiving module, used for receiving a cross-domain proxy request, wherein the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache strategy is set; the cross-domain proxy request is obtained by storing the location information of the resource to be accessed in a request header of a resource request message, wherein the location information of the resource to be accessed is obtained by replacing the receiving address information of the resource request message with the location information of the resource to be accessed with the target address information of the cross-domain proxy request, wherein the target address information is obtained by concatenating the address of the proxy server and the proxy identification parameter; and the cache strategy is to pre-cache a copy of the resource on the proxy server or the client; A resource request generation module, used to generate a resource acquisition request based on the location information of the resource to be accessed; A resource request sending module, used for sending the resource acquisition request to a resource server; A resource receiving module, configured to receive a response message sent by the resource server, wherein the response message includes the resource to be accessed; The message forwarding module is used to forward the response message to the terminal.
16. The device according to claim 15, characterized in that The resource request generation module includes a parameter generation unit, an address change unit, and a request generation unit; A parameter generation unit, used to generate verification authorization parameters according to the authorization information of the resource server; An address changing unit, configured to change the receiving address information of the cross-domain proxy request based on the location information of the resource to be accessed, and generate the receiving address information of the resource acquisition request; The request generation unit is used to add the verification authorization parameter to the request header of the cross-domain proxy request to generate the resource acquisition request.
Citation Information
Patent Citations
Cross-domain network resource request method and device for client
CN104410711A
Data processing method and device for realizing cross-domain request at webpage end and related equipment
CN111666514A
Cross-domain access implementation method and system for browser in application program
CN112261111A