Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish website "not found" error #834

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ For **assistance requests**, submit a post [on Stack Overflow](http://aka.ms/api

We welcome and appreciate **[community contributions](CONTRIBUTIONS.md)**. Refer to the **[contribution guidelines](https://github.com/Azure/api-management-developer-portal/wiki/Widget-contribution-guidelines)** for more information.

##<a name="fix"></a> Fix Publish from localhost designer mode
When opening localhost designer and trying to publish you may get CORS error:
Access to XMLHttpRequest at 'https://apimboris.developer.azure-api.net/publish' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

One way to solve this error while publishing from localhost:8080 is to disable CORS by passing parameters to Chrome via command line. For example, run the following command as administrator:
```
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=c:\users\cors-off
```

## <a name="license"></a> License

The developer portal is based on our own fork of the [Paperbits framework](http://paperbits.io/), which we enriched with API Management-specific features, and is published under [MIT license](license).
12 changes: 8 additions & 4 deletions src/components/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ import { Logger } from "@paperbits/common/logging";
import { IAuthenticator } from "../../authentication/IAuthenticator";
import { AppError } from "./../../errors/appError";
import { MapiError } from "../../errors/mapiError";

import { ISettingsProvider } from "@paperbits/common/configuration";

@Component({
selector: "content-workshop",
template: template
})

export class ContentWorkshop {
constructor(
private readonly viewManager: ViewManager,
private readonly httpClient: HttpClient,
private readonly authenticator: IAuthenticator,
private readonly settingsProvider: ISettingsProvider,
private readonly logger: Logger
) {
this.viewManager = viewManager;
this.viewManager = viewManager;
alert("content constructor - OK")
}

public async publish(): Promise<void> {
Expand All @@ -30,10 +33,11 @@ export class ContentWorkshop {
}

try {
const accessToken = await this.authenticator.getAccessToken();
const accessToken = await this.authenticator.getAccessToken();

const publishRootUrl = await this.settingsProvider.getSetting<string>("backendUrl");
const response = await this.httpClient.send({
url: "/publish",
url: publishRootUrl + "/publish",
method: "POST",
headers: [{ name: "Authorization", value: accessToken }]
});
Expand Down