My project directory structure is implement in a way that the frontend dir sits inside the main dir where index.js of server file lives.
The problem is when I try to route to a specific page on client /about for example.
The call will be made to the server and not to client. on the home page / the server sends the call to /frontend/build/index.js. How can I achieve the same result to other routes?
Problem was routes order on the index.js file of server
Related
When I set \p 8080 I can have calls to http://localhost:8080/ to interact with kdb+.
How can I do it for this url:
http://localhost:8080/somepath
?
The use case if for my app that send HTTP requests to the kdb process to get data from the DB. For react reasons that are out of scope here (see this) I can't use http://localhost:8080/.
By default the root server for the q webserver is located in a folder called html under your QHOME folder.
If you had a html document called mydoc.html then you could place it at, for instance,
$QHOME/html/example/mydoc.html
and reach it by calling
http://localhost:8080/example/mydoc.html
There is some info here: https://code.kx.com/q/kb/custom-web/
We let the golem package automatically create a Dockerfile for us and can run the docker image and see the app at the root directory: http://localhost:3838/?...
But we would like the app to appear in a subdirectory like http://localhost:3838/myApp/v1/?... so that we can set up the necessary proxying for Apache and have this and other apps all available from a single server.
We can manually edit the Dockerfile to copy a shiny-server.conf file with the following information:
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location /myApp/v1/ {
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
}
}
The above solution feels like a hack and we are hoping there is functionality inside of golem that will allow us to set the subdirectory at which the app will appear.
Unfortunately there is no way to include an nginx configuration inside the Dockerfile programmatically: {golem} tries to help with the creation of the file, but some things still need to be done manually.
Also, note that {golem} doesn't create a Dockerfile with a shiny server in it, it creates a standalone docker image that launches the app, so there is no shiny server running, just an R process. {shiny} being what it is, there is no way to natively run it on a given path, it's always at the root, on a port.
That being said, what you can do is either edit the dockerfile so that it also bundle nginx (or any other load balancer), so that you can serve the app on a path, or serve your application on another port, using the port argument of add_dockerfile(): that might be easier to configure it with you Apache proxy.
Colin
I'm experiencing some strange behaviour with a ColdFusion 11 server, which (among other things) publishes some web services accessed via both SOAP and HTTP. The server itself is Windows 2012, running IIS. Actual folder config is as follows:
IIS has two websites configured, 'BOB' and 'BOB_Services'. Both have been configured with the CF Server Config tool so that CF handles .cfc, .cfm files. They share a common CFIDE config.
BOB's root is I:/inetpub/BOB
BOB_Services's root is I:/inetpub/BOB_Services
There is a folder mapping configured in CF Admin from '/' to 'I:/inetpub/BOB'. Don't ask me why, no one seems to know.
Normally there is a services.cfc file in BOB_Services ONLY. Yesterday we accidentally copied that same file into the BOB root folder, and all of our SOAP services using BOB_Services\services.cfc started throwing errors. Yet I can query the same webservice via HTTP (eg. using http://bob/services.cfc?method=function1¶m1=0 ....etc) and get a valid result.
This is a reference answer in case anyone else comes across this strange behaviour.
It appears that when BOB_Services/services.cfc is called using HTTP GET, the folder mapping
'/' -> 'I:/inetpub/BOB'
is ignored and the actual file used to process the request is I:/inetpub/BOB_Services/services.cfc.
When a function in BOB_Services/services.cfc is called using a SOAP client, the folder mapping is invoked and the file used to process the request is I:/inetpub/BOB/services.cfc, IF IT EXISTS. If it does not exist, the file I:/inetpub/BOB_Services/services.cfc is used as expected.
This behaviour appears to be entirely repeatable - I can make a SOAP request, get one result, change the mapping, make another request and get the other result.
Our problem with ColdFusion 10 is that there is the /rest/ URL binded. In our application we have a rest service ourselves. Since ColdFusion 10 it will not work because the URL is already defined and our requests won't get through. Is there any way to disable /rest/ completely? Or do we have to rename our service?
I also tried to edit the axis2.xml file
<parameter name="disableREST" locked="true">true</parameter>
<parameter name="restPath">restdisabled</parameter>
But that won't effect anything on the server.
Thanks in advance!
Disclaimer: I have not tried this and do not have a ColdFusion 10 installation nearby to verify
There is a servlet mapping defined in the web.xml file that defines how to handle /rest/ requests for ColdFusion. So you should be able to rename that URI to something else for your implementation. The web.xml file is located under the wwwroot\WEB-INF directory on your ColdFusion server.
I found some reference to this here - Getting started with RESTful web services in ColdFusion (under the Accessing a REST Service through HTTP section)
That documentation also mentioned updating the uriworkermap.properties file. Here is an excerpt from that page:
rest in the URL specifies that the request is for a REST service. ColdFusion has a servlet mapping for the same and would direct the request to the servlet that handles REST service. If there is a directory in the server webroot with the same name, you must update the servlet mapping in web.xml file inside wwwroot\WEB-INF directory. Also, you must update the same mapping in the uriworkermap.properties file located under the config\wsconfig\1 of the server directory.
You will need to restart the ColdFusion service after making any changes to these files.
While this will not disable the functionality in ColdFusion it will allow your services to respond under the /rest/ URI because ColdFusion will be listening under a different one that you define.
I am trying to include a module in Phalcon Micro Application. Is that possible?
I have a structure like this
common/
components/
...
modules/
system
components
...
controllers
...
rest
components
...
controllers
...
www
controllers
...
www/
index.php -> Loads /Phalcon/Mvc/Application($di);
api/
index.php -> Loads /Phalcon/Mvc/Micro($di);
The www registers the modules from config
I want the api to register the rest module from config and include the controllers and the components of that module. Is that possible?
Thanks,
Gasim
Obviously all is possible !
If you want to keep your structure with application+micro I think the best way is to create 3 configs.
A first config that is common with both of api and www
A second one which is loaded only by your www with its one router
A thirds one which is loaded only by your api with its one microrouter and which redefines the different paths to the rest module.
If you want just to use a multi module application with a single config file, then I can advice you to use the domain recognition in your router thanks to the setHostName() method.
Then in your config file you define an api hostname and a www hostname that you use everytime. You may also put them in global constant for more convenience.
// an api get route
$router->add("/getsomething",...)
->via("GET")
->setHostname(MyApp::HOSTNAME_API);
// an api post route
$router->add("/postsomething",...)
->via("POST")
->setHostname(MyApp::HOSTNAME_API);
// a www route
$router->add("/",...)->setHostname(MyApp::HOSTNAME_WEB);
I am trying to include a module in Phalcon Micro Application. Is that possible?
Yes, no problem!
I want the api to register the rest module from config and include the controllers and the components of that module. Is that possible?
Looking at your description and structure I understand it as you would like to separate the configuration of the www module and api module. This will work fine and you only need to include your api configuration in www/index.php (since that is where you start your application and where all your requests will go). Good luck!