Javascript-questions about frontend and backend collaboration

Source: Internet
Author: User
Suddenly I think of a problem. Will the front-end run the entire project on its own computer, or is there only front-end code? if there is only front-end code, isn't it an absolute path when using the back-end interface? Suddenly I think of a problem.

Will the front-end run the entire project on its own computer, or only the front-end code?

If only the front-end code is used, isn't an absolute path used for the back-end interface?

Reply content:

Suddenly I think of a problem.

Will the front-end run the entire project on its own computer, or only the front-end code?

If only the front-end code is used, isn't an absolute path used for the back-end interface?

Currently, the development of frontend and backend separation and collaboration is quite popular:

  1. The front-end and back-end code is still put in the same project, but the complementary influence is made during the development process;

  2. In the early stage of development, determine the requirements first, and then define the required interface data;

  3. During the development process, the front-end simulates the real running environment by mock data of the defined interface; the backend should also have the corresponding restfull interface testing tool, which does not need to be concerned;

  4. After the test is completed, call the real backend interface for joint debugging test;

There are two ways to display pages
One is to call the backend method to process data and then render the page. The other is to execute the front-end code and request data using js.

If you access the same project, you can use the relative path. Otherwise, use the absolute uri path.

We now have only some code in the previous section on our computer,
Of course, cross-domain communication with the server may occur in this case,
Chrome has a plug-in cors that allows cross-origin to be useful.
The path is the ip address of the server code you need to call + the interface path.

Now we generally build a test server. The frontend and backend Upload The prepared modules to the test server based on the development progress. in this way, the modules are actually written locally and run on the server, so you will say that it is not annoying to modify and upload each time. for example, Sublime text has a SFTP plug-in that automatically modifies and uploads the files. as a result, all the code is unified on the test server, after the test is passed, the code of the test server is transferred to the master server.

The front-end code is written in basepath. this value is obtained by reading the configuration file when the project is started. just configure the server address for it. Cross-Origin problems are solved by using cors-filter and java-property-utils in web. xml configuration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.