• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Front End configuration to connect to back end

 
Tim Cooke
Sheriff
Posts: 4705
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi web savvy folks, I have a problem, and that problem is most likely caused by my lack of front end web technology skills.

I have a web application that consists of two separate projects, a Java backend system that exposes a REST API, and a front end HTML, JS (actually Vue) system that uses that API. The problem I have is that the URL location of the API is hard coded into the front end JS code which means a code change and new versioned build is required to deploy it to different environments. This is not ideal.

My question is: Is it possible to define some external configuration values for a front end html and js web application? Somewhere I can define properties that may change over time?

Thanks, Tim
 
Norm Radder
Rancher
Posts: 3623
34
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can it be loaded from a small external .js file?

 Somewhere I can define properties


How to have separate files that the front end can get data from for its specific location?
 
Bear Bibeault
Marshal
Posts: 67313
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your project have a package.json file? (If you are using npm or other front-end tool chain you should have one.)

If not, the simplest solution might be to simply have a JS file that contains constants with config values.
 
Tim Cooke
Sheriff
Posts: 4705
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do have a package.json file but that is part of the code repository and as such falls under the scope of a versioned build in our deployment pipeline. Updating a value in here would be a version bump which is not ideal when all I want to do is deploy the same build that's been tested in our testing environment into our production environment.

Norm and Bear your suggestion of using a separate JS file that contains only constants for config values might just work and I can keep that separate from the versioned package code. Just the same as I would maintain an application.properties file for a Java app separately.

Nice one, thanks!
 
Tim Cooke
Sheriff
Posts: 4705
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been chatting to my front end guy and he was wondering how you might manage this kind of config setup outside of the packaged code, that is all the js code that gets packaged into a single file, as there are no imports to reference the separate JS file? Same question for the package.json idea?
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!