Changing localhost:9002 for exposing API - sap-commerce-cloud

I am trying to get the api working on an Azure VM. The url won't be https://localhost:9002/rest/v2/ext/basestores/ext anymore, but otherUrl:9002/rest/v2/ext/basestores/ext.
Could somebody tell me where to look for that?
Many thanks :)

Not sure if I got your question correctly, but at least from Spartacus point of view, you can define backend.occ.baseUrl configuration to any URL you need.
Here is the basic example:
B2cStorefrontModule.withConfig({
backend: {
occ: {
baseUrl: 'https://localhost:9002',
prefix: '/rest/v2/'
}
},
}),
And here are docs how to set-up Spartacus:
https://sap.github.io/cloud-commerce-spartacus-storefront-docs/building-the-spartacus-storefront-from-libraries/#adding-import-declarations-and-storefront-configuration-settings

Nothing to do with hybris. In your hosts file add an entry-
127.0.0.1 otherUrl

Related

Azure Application Gateway - question about override backend path

I've been working with the Azure Application Gateway for a while and I have some doubts about the Override Backednd Path option. I would appreciate if someone could clarify if my reasoning is correct.
Assumptions:
listener: mysite.mycompany.com
backend: myserver1.mycompany.com / myserver2.mycompany.com
HTTP Settings:
Override backend path: /images
Override with new hostname: Yes -> Pick hostname from backend target
Based on the settings above, if I send a request to mysite.mycompany.com, how will the App Gw forward it? My assumption would be that it will forward it to either myserver1.mycompany.com/images or myserver2.mycompany.com/images, but that does not seem to work properly.
Regards,
Wojtek
I send a request to mysite.mycompany.com, how will the App Gw forward it?
My assumption would be that it will forward it to either myserver1.mycompany.com/images or myserver2.mycompany.com/images, but that does not seem to work properly.
That's exactly how it works.

ASP.NET Core This localhost page can’t be found

Does anyone encountered this kind of problem? I think it has something to do with the IIS or so... I am using IIS 10 also using VS2017 and ASP.NET Core. When I launch the application I saw this error:
This localhost page can’t be found
No webpage was found for the web address: http://localhost:44306/
I tried changing the port. But nothing works.
I tried other application it works but only this project having this kind of error and I don't know why.
Any Idea how to fix this?
Update:
I solved this problem when I realized I had accidentially removed the default route in the StartUp class' Configure method:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
This is similar to #ToMissTheMarc answer, but shows how to define routes in .Net Core version 3.0
I was having a similar problem when trying to hit my API endpoint https://localhost:44380/api/Restaurants
In order to map my routes for an API controller class that inherited from the ControllerBase class, I needed to add the line endpoints.MapControllers to Configure method of Startup.cs class, as follows:
//Pre .NET core 3.0 way of doing things
//app.UseMvc(routes => {<some routing stuff here>});
//.NET core 3.0 way
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages(); //Routes for pages
endpoints.MapControllers(); //Routes for my API controllers
});
If the answer above doesn't work or you're coming from the .NET Web API tutorial, this might help. So for me, I removed the launchUrl property from launchSettings.json because I wanted to use a static page (per the instructions of the tutorial I'm following) and forgot to add 2 lines in my haste. I finally went back and looked over it and this solved my issue.
Open the Startup.cs file and inside public void Configure... add the following above the app.UseMvc(); line:
app.UseDefaultFiles();
app.UseStaticFiles();
I faced the same problem but the mistake was a silly one hence the solution very easy!
there was a typo in my route
I added a space by mistake after Controller Name
I know its not very Technical Answer but it won`t harm to double check
was:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("Default", "{controller= Home}/{action=Index}/{id?}");
});
Corrected to:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("Default", "{controller=Home}/{action=Index}/{id?}");
});
Had the same problem, it turned out I unintentionately changed my Index() method of HomeController to property through refactoring
public ViewResult Index() => View()
became
public ViewResult Index => View();
In my case, I modify the index name to HomePage, and I resolve it by check several places:
(You can search index in your entire solution to check)
In Views/_Layout.cshtml
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="HomePage">xxx</a>
In Startup.cs
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=HomePage}/{id?}");
});
In Controllers/HomeController.cs
public IActionResult HomePage()
{
return View();
}
After I edit the three places, it works well.
Make sure project, lauchsettings.json ports are set correctly.
if this is happening you are missing wwwroot folder.
This was happening to me because I had copied a .net core 1 Razor Page into my .net core 2.2 project. I added a #page declaration to the Razor Page and everything worked. Just adding this here because this is the first Google result for this issue.
Be sure to check and try these items:
Change port number in project properties.
Reset IIS in cmd using "iisreset" command.
Checked the StartUp.cs to ensure
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Restarted VS and laptop but to no avail too.
Checked launchSetting.json but everything is correct.
In my case it was just switching to another localhost's port that ISS provided while launching. On the first one there was an error "page not found" but second one worked as it supposed to.
In your project, go to properties -> launchSettings.json (double click)
in iisSettings -> iisExpress -> applicationUrl (change the port number for your localhost)
and try again, issue should be solved successfully.
This happens every time I add a razor page to my project.
The solution is to, in Visual Studio, click on the cshtml file and then set "Build Action" from "None" to "Content". Fixes the issue every time (for me).

Changing the default Sails public folder

I know from experience that Sails creates a ./.tmp/public/ folder from where it serves all my files. I'd like to change it to just ./public/
I read a GitHub issue that said I could do it in config/local.js, but that doesn't seem to be working. Here's the GitHub issue: https://github.com/balderdashy/sails/issues/709
Is there a way to accomplish this? Thanks.
As to why I'm trying to do this, it's because I'm actually trying to work with Sails and Parse to build a simple test application. Since Parse looks in the ./public/ directory by default and I couldn't find a way to change this behaviour, I'm trying to configure Sails.
Create a file config/paths.js with the value:
module.exports.paths = {
'public': 'assets/'};
As in the mentioned issue report it can either be done in the .sailsrc file
{
"paths": {
"public": "bar/foo"
}
}
or if you launch sails in your own app (no using sails lift)
var Sails = require('sails');
Sails.lift({
paths: { public: 'mydir/pub' }, // relative to appDir
}, function(err, server) {});
If your using out of the box Grunt tasks, then you will need to go through and edit those tasks in <root>/tasks/config, there does not seem to be an global config variable for this, so you might have touch each file.
http://sailsjs.org/documentation/anatomy/my-app/tasks/config

How to use the ChromeApp to connect to a node.js server?

I have a Node.js server and I'd like to know how I could do for the ChromeApp to work with it. I tried putting "http://localhost:3000" (server address) on the runtime:
chrome.app.runtime.onLaunched.addListener(function () {
chrome.app.window.create('http://localhost:3000');
});
But it doesn't even launch. Does someone have an idea on what I could do?
Thanks.
You cannot launch external URLs with chrome.app.window.create. In fact if you check the chrome.runtime.lastError property you will see the following error:
The URL used for window creation must be local for security reasons.
I suggest you look into using the <webview> tag as it is much more appropriate for your use-case.

Create folder from chrome extension

I am developing chrome extension where I am trying to create a folder from extension to save some of the files. I believe there are some security constraints for this but I am not sure if this can be done if yes could someone please guide me how to do this? I have tried FileSystem APIs but I was not able to physically see where the file was created and access it.
Thanks in advance.
The html5rocks article gives an overview of how to create all of this.
This is how you create a directory
window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) {
fs.root.getDirectory('MyPictures', {create: true}, function(dirEntry) {
...
}, errorHandler);
}, errorHandler);

Resources