Dynamic request between development and production environment

Asked

Viewed 34 times

0

I would like to know how to solve the request problem between a local and production environment.

Example:

I have a JS function that takes the application content and concatenates with the request.

var ctx = window.location.pathname.substring(0, window.location.pathname.indexOf("/",2));

ctx+'/Portal/listaProdutos'

Locally would: localhost:8080/"application name"/Portal/listProducts

But in production, the requests are taking the duplicate context: www.nomedosite.com/Portal/Portal/listProducts.

How to solve this problem?

Another tip:

I also have request like this: ctx+'/carregaBarSearch', and I’m browsing pages with the context /Portal , www.nomedosite.com/Portal/Home

1 answer

1


You should set a static dns or ip for your servers and set as the base path of your requests.

  • Oops, in real I just need to know what the dynamic context would look like in JS.

  • Dear in my design, you must define a global variable and in a given moment use an ajax to get this information from the server. maybe it was the right way.. but then comes the question that you don’t have the server address to use to make an ajax. So I guess.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.